Kor*_*nel 4 iphone cocoa-touch xib
我想我找到了原因:IB中的文档信息窗口有一个警告:"'选定的导航控制器(第二个)'将nib名称属性设置为'SecondView.nib',但是这个视图控制器不打算有它的视图以这种方式设置."
游民.
我在Interface Builder中构建了nib,它UITabBarController位于顶层并在UINavigationControllers 之间切换.
当一切都在一个nib文件中时,它工作正常,但我想nib为UINavigationControllers 使用单独的文件.
从Apple的TabBar模板开始,如果我只是将SecondView的类更改为UINavigationController,它会破坏:
我得到的就是这个:
// imgur has lost the image, sorry //
Run Code Online (Sandbox Code Playgroud)
是否有可能UINavigationController没有以编程方式设置所有内容的单独文件?
我想TabBarController处理笔尖的加载和卸载.
我还没有尝试通过IB设置UINavigationController.我有多个屏幕,每个屏幕存储在单独的xib中,并且有一个扩展UIViewController的相应类.在applicationDidFinishLaunching中,我使用xib初始化UIViewControllers,然后手动创建UINavigationController,将导航控制器的视图添加到窗口并将第一个视图推送到导航控制器.
不确定这是否有帮助.
- (void)applicationDidFinishLaunching:(UIApplication *)application {
navigationController = [[UINavigationController alloc] init];
FirstViewController * viewController = [[FirstViewController alloc]
initWithNibName:@"FirstView"
bundle:nil];
[navigationController pushViewController:viewController animated:NO];
[viewController release];
[window addSubview:navigationController.view];
[window makeKeyAndVisible];
}
Run Code Online (Sandbox Code Playgroud)
上面的FirstViewController扩展了UIViewController,在IB中你创建了你的视图然后将File的所有者类设置为你的类(例如这里是FirstViewController)并将File的所有者视图连接到UIView的视图.
只需将UINavigationController与FirstViewController交换即可.
层次结构应该是这样的:
Tab bar controller
-----Tab bar
-----Navigation Controller
----------First View Controller
---------------Navigation Item
----------Tab bar item (First)
-----Navigation Controller
----------Second View Controller
---------------Navigation Item
----------Tab bar item (Second)
Run Code Online (Sandbox Code Playgroud)
您将检查器中的First View Controller的nib设置为包含实际视图对象的nib文件(因为您尝试将它们拆分为单独的文件,这是一件好事).
您有一个选项卡,该选项卡有一个导航控制器,可以将First View Controller作为其根视图加载.
完成.
| 归档时间: |
|
| 查看次数: |
11554 次 |
| 最近记录: |