UINavigationController 在另一个 nib 文件中开始?

发布于 2024-11-02 11:17:30 字数 314 浏览 0 评论 0原文

当程序启动时你看到的第一件事是,我成功地设置了一个工作导航控制器,但是当它来自主窗口以外的 nib 文件时,我就失败了。

我希望我的主屏幕与导航控制器没有任何关系,但是当您单击设置按钮时,您将被带到另一个 nib 文件,该文件是根目录,从那里您可以将新的视图控制器推送到它上面 我读过无数的

例子,但它们都专注于从一开始就创建一个导航控制器(在AppDelegate中设置窗口rootViewController),并且我找不到任何适用于我的情况的东西(但看起来像应该很简单!)。

任何关于做什么或去哪里寻找的建议将不胜感激......谢谢。

克里斯

I've been successful in setting up a working navigation controller when it's the first thing you see when the program launches, but I've been unsuccessful when it's from a nib file other than the Main Window.

I'd like my main screen to NOT have anything to do with the navigation controller, but when you click on the settings button, you are then taken to another nib file which is the root and from there you can push new view controllers onto it, etc.

I've read countless examples, but they all focus on creating a navigation controller right from the beginning (setting the window rootViewController in AppDelegate), and I can't find anything that applies to my situation (yet it seems like it should be really simple!).

Any advice on what to do or where to look would be appreciated... thanks.

Chris

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

虐人心 2024-11-09 11:17:30

只需在窗口上添加导航控制器即可。

  1. 删除窗口上添加的视图(主视图控制器)
  2. 将子视图添加到窗口导航控制器

为此目的,在应用程序委托中创建一个方法并从主视图控制器调用它

// method in app delegate looks like
-(void) switchViews {
    // mainViewCont is instance variable on app delegate of the main screen
    [homeViewCont.view removeFromSuperview];
    // navCont is instance variable on app delegate for navigation controller
    [self.window addSubview:navCont.view];
}

Just add the navigation controller on window.

  1. Remove view added on window (the main view controller)
  2. Add subView to window the navigation controller

For that purpose create a method in app delegate and call it from your home view controller

// method in app delegate looks like
-(void) switchViews {
    // mainViewCont is instance variable on app delegate of the main screen
    [homeViewCont.view removeFromSuperview];
    // navCont is instance variable on app delegate for navigation controller
    [self.window addSubview:navCont.view];
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文