It happens that the IBOutlets in the new project are connecting to the storyboard of the original project? How to avoid? Or how to disconnect from the ViewController code?
Here you can see MainStoryboard_iphone is storyboard in original project, Main_iPhone_storyboard is storyboard in the new project.
Thanks.
I would suggest a simple hack if you don't have a lot of classes - create new files for every header file where you declare your IBOutlets and copy over the code - it might as well solve the problem.
Related
i have used an imageview in the ios builder in visual studio whose refrence is automatically connected to my viewcontroller class and when i do set image to that imageview my app crashes with an error "This class is not key-value complient for the key image__"
As i am new to xamarin i am not aware if we need to do anything else inorder to make relation from storyboard to the class variable for access that particular outlet object.Please suggest me if you have any advice?
Open the storyboard in visual studio and then open properties pad. Select the image view and give Name in the identity option. Outlets from Xcode did not work in xamarin.
For example, your view controller name is TestView and you give the Name to image view as MyImage. Now there is one more file named TestView.designer.cs open that file and you will see that Outlets are generated in that file.
You might have accidentally removed the connection.
Is your imageView name: image__?
Given if the imageView is in ViewController.cs, look at the Solution Explorer, expand and find the ViewController.designer.cs and remove the imageView or image__(in your case) Outlet and whatever that's related to it and then re-link the Outlet again.
The problem was that the refrence was not working properly. I just removed the image outlet and viewController class and closed the project.Then i started creating that same class from very scratch and created the outlet from the storyboard. That was it. Everything started working COOL..!!!
I hope restarting the project helped me and it can help you too.Good Luck.
I create a new ViewController and renamed class. But still, the .h file where I want to store outlets and action doesn't appear.
In your xib or storyboard file change the Class in File's Owner to mach the one you had renamed.
See image:
When you add a new view controller and you think files *your controller name*.h and *your controller name*.m should automatically create. In my case, I start building a project(not in Visual Studio) in XCode. And after that, my files appear.
So, I was following along a core-data tutorial RayWenderlich.com part 1/3 circa 2012 using Xcode 8. Naturally some things are different now, like the default view controller and storyboards vs xib being used.
So rather than explicitly creating a xib for the MasterViewController, etc. (I instead did things the Xcode 8 way), I just renamed the supplied ViewController, and the associated .h and .m contents to MasterViewController. All was fine until I got to the step to add its outlet in the app delegate.
No joy.
Snippet shows the outlet is there but I cannot link to it.
I uploaded the project to ScaryBugsMac on github as I'm stuck what's wrong. Tried suggestions on similar question to remove/add, import vs include for the header, and to publish the outlet by putting it in the app delegate header.
I'm thinking the rename isn't being handled but I want to know how it's broken and how to fix it.
Well I punted and restarted, this time without renaming the controller. Find "part 1" of the tutorial in ScaryBug on github.
Using Xcode do I need to create a new file for each view when it is connected to a button? Or does it work fine with just keeping the app under one h and m file?
Create a new file for each view. This will give you a new .h and .m file. Using MVC or single app view.
iOS app development follow the model-view-control design pattern, and as such, you should always create a new control (.m and .h file) for each new view.
I realized that when launching assistance editor while working on a XIB file no longer opens the header file by default, instead it shows the implementation file. Is there a new workflow going on I am not aware of? While in the implementation file I can only seem to be able to add IBActions. What is the "new" way to create IBOutlets? Switching to header file each time??
My 2 Cents:
When you create a new class using the Xcode templates, it usually provides a class extension in the implementation file for private properties. It makes a lot of sense to actually link the IBOutlets and IBActions there, because in most cases they are only ever used within the class itself.
The only exception to this that crosses my mind right now is UIView subclasses, and especially UITableViewCell. A lot of developers access the IBOutlets directly in cellForRowAtIndexPath:.
Apple engineers' message:
Encapsulate your IBOutlets & IBActions whenever possible!