开发者

Loading a UINavigationController from a nib

开发者 https://www.devze.com 2023-04-02 04:49 出处:网络
I have the following code:开发者_StackOverflow中文版 UINavigationController localNavigationController = [[[NSBundle mainBundle] loadNibNamed:@\"CustomView\" owner:self options:nil] objectAtIndex:0];

I have the following code:开发者_StackOverflow中文版

UINavigationController localNavigationController = [[[NSBundle mainBundle] loadNibNamed:@"CustomView" owner:self options:nil] objectAtIndex:0];

And here's the CustomView.xib

Loading a UINavigationController from a nib

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...

0

精彩评论

暂无评论...
验证码 换一张
取 消