iphone - 如何在 Interface Builder 中创建以 UITableViewController 作为根的 UINavigationController?

标签 iphone ios xcode xcode4 interface-builder

1)在我的应用程序委托(delegate)中,我创建了 Root View Controller ,它是一个导航 Controller :

self.navigationController = [[UINavigationController alloc] initWithNibName:@"RootNavigationController" bundle:nil];
self.window.rootViewController = self.navigationController;

2) “RootNavigationController.xib”创建一个 UINavigationController。它还定义了一个 Root View Controller ,它是一个 CatsViewController : UITableViewController。有一个 CatsViewController 文件和一个带有 UITableViewController 根对象的“CatsViewController.xib”。就像您在此屏幕截图中看到的那样,我相应地设置了 NIB 名称:

enter image description here

问题是,即使存在 CatsViewController.xib 文件,Xcode 也不让我从下拉列表中选择 CatsViewController。我希望 UINavigationController 的 XIB 创建一个 CatsViewController 实例作为它的根,并且我想通过单独的 nib 文件配置此根 Controller 。

Xcode 警告:

enter image description here

有办法吗?

最佳答案

您收到的错误是由于 AppDelegate 中的 didFinishLaunchingWithOptions 方法尝试初始化窗口而不仅仅是返回 YES。

还在您的代码中更改 RootNavigationController,例如:

self.navigationController = [[UINavigationController alloc] initWithNibName:@"RootNavigationController" bundle:nil];

改成

self.navigationController = [[UINavigationController alloc] initWithNibName:@"CatsViewController" bundle:nil];

关于iphone - 如何在 Interface Builder 中创建以 UITableViewController 作为根的 UINavigationController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12873663/

相关文章:

ios - 在 Swift 中快速更新 UIView 背景颜色?

ios - 用户登录哪个 App Store

ios - Swift 面向协议(protocol)的扩展

iphone - iOS应用内购买: Can Non-Consumable Apple Hosted Content be Free

iphone - 检测 iOS 应用程序是否在调试器中运行

ios - 未调用 UITableView setter 方法函数

ios - cocoapods - 链接器命令失败,退出代码为 1

iphone - 将单独的 iPhone 和 iPad 项目转换为通用项目

iphone - 在 iPhone 应用程序中使用单选按钮

iphone - 在 iOS 的 Objective-C 中,如何在类 View Controller 中使用 slider 来更改 AppDelage 中播放的歌曲的音量?