从笔尖加载UINavigationController

时间:2011-09-05 04:24:25

标签: iphone objective-c uinavigationcontroller

我有以下代码:

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

这是CustomView.xib

enter image description here

我接错了吗?我收到以下错误:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIWindow setParentViewController:]: unrecognized selector sent to instance 0x5b74fe0'

1 个答案:

答案 0 :(得分:0)

如果你正在加载NIB,并要求索引0处的对象,那不就是UIWindow吗?你在哪里使用导航控制器?如果您在主应用程序中使用它,为什么不直接创建iVar和它作为IBOutlet的属性并将其连接起来?它将自动为您加载...