How to instantiate a ViewController programmatically since XCode 4.5 does not have ViewController Identifier? - xcode4

I need to instantiate a ViewController programmatically using Storyboard, because this ViewController is only called conditionally (It is loaded when a UIBarButtonItem is present, which is conditional).
I understand that I can do this by calling this method instantiateViewControllerWithIdentifier:(NSString *)identifier from UIStoryboard, as directed by this Apple Developer Guide (see under Instantiating a Storyboard’s View Controller Programmatically).
This is all well and good until I'm stuck with the identifier, because XCode 4.5 Interface Builder does not have an identifier attribute under the Attributes Inspector. It only has the Storyboard ID under the Identity Inspector, which doesn't really help.
Anyone has any idea how to solve this problem?

Related

Xamarin.Mac -- AppDelegate DidFinishLaunching -- Is the "Main Interface" specified in Info.plist already supposed to be loaded?

I have an existing .xib that needs to be displayed as the main page in a Xamarin.Mac application. If I set the "Main Interface" as this existing .xib, it does display but it's not done by the time my DidFinishLaunching override gets called. This is where I expect to do some initialization, but the outlets I specified are all null.
I am new to Xamarin and I'm trying to figure out if I need to override a different call that lets me know that the main page is done loading or if the issue lies elsewhere.
I did see that an NSWindowController has a WindowDidLoad override, but if I set the Main Interface in the info.plist, how does it know what the ViewController is for that view so that my override WindowDidLoad gets called?
I'm thinking I probably need to create the main window manually in DidFinishLaunching, but I can't find any documentation on how to create the main window through an .xib. There is documentation on how to get a storyboard from a nib, but I am not seeing anything on loading a .xib. If someone can find a good reference on how the main window gets initialize (with all the plumbing included) in a Xamarin.Mac application, that may be enough.
Thank you in advance for your time.
The chain of events is roughly:
Main invokes NSApplication.Main
Reads Info.plist to determine what xib/storyboard to load.
Storyboard is loaded and inflated. The view controller has a custom class that points to "ViewController"
Your ViewController is spun up, and WindowDidLoad get called.
DidFinishLaunching is not exactly what you are looking for.
May I suggest take a look at the documentation in question to get a better understand of the full process:
https://developer.xamarin.com/guides/mac/getting_started/hello,_mac/#Anatomy_of_a_Xamarin.Mac_Application

How to unwind from UINavigationController to UIViewController?

I'm trying to use an unwind segue from a UINavigationController subclass to a UIViewController subclass. My issues arise arise (I believe) because my navigation controller is the root view controller of my UIWindow. I attempted to set my UIViewController as the root and then modally present the navigation controller before my AppDelegate finishes launching, but that doesn't work because the view is not added to the hierarchy.
Any ideas?
EDIT:
Is there anyway to attach a segue to the top view controller of the navigation controller? I have a fairly large storyboard and would like to avoid repeating myself on multiple controllers.
I'm currently struggling with using unwind segue past navigation controller myself too but maybe that article I found can help you. It describes (with GitHub project attached) how to use unwind segues whilst under the aegis of a UINavigationController:
https://github.com/simonmaddox/CustomUnwindSegue/tree/master
PS - Regarding your Edit: If you can get it to work following SimonMaddox steps in the link I suggested, the method should then work from any ViewController under the Navigation Controller I think.

Why does Caliburn.Micro call PropertyChanged

I've a class which does not have a base class nor implements INotifyPropertyChanged.
In my application one object of this class is used as the viewmodel for 2 views (master and detail).
If I create the bindings to the properties by convention (x:Name). I see that when I change a property in the detail view it is also updated in the master.
This does not happen when I use the normal binding syntax.
Can anyone explain me why this happens ? Is this a feature of Caliburn.Micro ? I couldn't find it in the documents.
=== edit ==
I just found out that when using normal binding that the other view also get's updated only after the text box loses focus.
Still the question remains how can a View react to a change in the viewmodel when propertychanged is not implemented.
Thanks in advance,
Marwijn.
Caliburn.Micro binds properties with BindingMode.TwoWay by default.
If you did not specify this explicitly in your own binding - you've used OneWay.

I can't change initial Xcode storyboard view

I'm trying to change my initial view in my storyboard, but, when I change it I get this strange view:
Anyone can tell me why?
Ps: In my project I don't have any tab controllers, so I don't know why there is a tab over there...
Is it possible you are doing a universal app and are looking at the wrong View?
What you have there is a navigation bar in a blank view and probably a message in your messages telling you that you have not got a root view controller.
In the past I have solved this by
a) Restarting XCode.
b) Making a new view, copying and pasting the essential View Controller from my old View and deleting the old View.
c) Checking in my summary that the view I think is being talked to actually is the one specified.
d) Looking at my storyboard and checking that the viewcontroller is specified in the object inspector as "Is initial View Controller" by checking the box.

Swiz framework with AIR - Using ViewAdded/ViewRemoved on child windows?

I'm trying to implement a popup window (NativeWindowType.UTILITY) in an AIR 2.7 application that uses Swiz for dependency injection.
I have followed the Swiz guidelines that I've been able to find, and implemented ISwizAware on the class that creates the window, and I am calling _swiz.registerWindow() before opening the window, and dependency injection works fine on the window itself after this.
However, the problem I am running into is that I have a child view within that window, and I have a mediator that uses the [ViewAdded] and [ViewRemoved] tags. Neither the view added nor view removed functions are triggering. I'm thinking the issue is either:
The child view is not correctly registering with Swiz.
The swiz instance doesn't know about the beans (I have tried manually adding the bean however, which didn't have any effect).
The ViewAdded and ViewRemoved metadata tags simply aren't working because each NativeWindow object has its own stage instance.
Anyone know more about this?
Popups are a special case since they don't get added under the same display tree as your application. Under Stage (the main wrapper for Flash Player), you'll have Application where your code resides for Swiz, but Popup is in a separate layer above Application. Since they're siblings, Swiz cannot listen in for when the popup is being added to the Stage.
The way around this is to either set the properties of the popup manually (which is normally the easiest way) or manually add the popup to Swiz's awareness. For this you'll have to look at the documentation since I haven't touched Swiz in a long time.

Resources