xcode - 添加使用 IB 构建的 UINavigationController

标签 xcode ios interface-builder uinavigationcontroller

构建 iPhone 应用程序。委托(delegate)加载一个 SplashScreenView,它会一直驻留在那里,直到用户点击屏幕。当用户完成点击屏幕后,我释放该 View 并想要加载我的自定义导航 Controller 。我不知道如何加载我在 IB 中设计的导航 Controller ...它当前正在加载 UINavigationController 的空白实例。

我从我的委托(delegate)运行这个:

mnc = [[MyNavigationController alloc] initWithNibName:@"MyNavigation" bundle:nil];
[self.window addSubview:mnc.view];

MyNavigation 是我创建的 XIB,其中仅包含我添加的文件所有者/第一响应者/导航 Controller 。我将文件所有者的类设置为 MyNavigationController,但我不知道如何告诉它我希望 View “MyNavigationController”成为我设计的 View 。当我尝试将IB中文件所有者的“ View ”导出拖到我设计的导航 Controller 时,它似乎不喜欢它。

我只是不确定如何将这里的点连接起来。任何帮助将不胜感激。

最佳答案

您的导航 Controller 的根 Controller 是什么?您看到的“空白”东西可能是您的导航 Controller 加载了没有可供导航的 Controller 。

更新

您本身不需要“两个 Controller ”。只是导航 Controller 是控制您提供的其他 Controller 堆栈的 Controller 。首先,您使用 Root View Controller 初始化导航 Controller (使用您提到的 initWithRootViewController 方法),然后您可以推送 (pushViewController:animated:) 或 pop (popViewController:动画:)其他 Controller 进入或离开导航 Controller 堆栈。

Apple 开发人员文档在 View Controller 编程指南中提供了有关不同类型的 View Controller 如何交互的大量信息。

关于xcode - 添加使用 IB 构建的 UINavigationController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5250420/

相关文章:

xcode - 分布式 dylib 的链接器设置

ios - Visual Studio Team Services ***NO_CI*** 不适用于 Bitbucket 和 Xcode

ios - Swift 中的希伯来字符

xcode - Xcode 在命令行工具中创建的 "foo.1"文件是什么?

ios - kCLAuthorizationStatusRestricted 显示在我的一个应用程序中,但同一设备上的另一个应用程序中没有显示

ios - CollectionViewCell效果

ios - 由于 'internal' 保护级别 swift 4,扩展初始化程序无法访问

ios - 在 Storyboard中使用 Xib 时,Xib 的 IBOutlets 返回 nil

ios - 如何在不为每种语言创建 xib 的情况下本地化 xib View 中的文本?

iphone - 使用 Interface Builder 构建的自定义 UIView 可通过 Interface Builder 访问/定位