Loading a UINavigationController from a nib
I have the following code:开发者_StackOverflow中文版
UINavigationController localNavigationController = [[[NSBundle mainBundle] loadNibNamed:@"CustomView" owner:self options:nil] objectAtIndex:0];
And here's the CustomView.xib
am I wiring it wrong? I am getting the following error:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIWindow setParentViewController:]: unrecognized selector sent to instance 0x5b74fe0'
If you are loading the NIB, and asking for the object at index 0, wouldn't that be the UIWindow? Where are you using the navigation controller? IF you are using it in your main application, why don't you just create an iVar and a property for it as an IBOutlet and hook it up? It will automatically get loaded for you...
精彩评论