【问题标题】:Is it possible to present an UINavigationController from another UINavigationController?是否可以从另一个 UINavigationController 呈现 UINavigationController?
【发布时间】:2020-09-12 05:08:57
【问题描述】:

我有一个 UINavigationController 包含一个 UIViewController。 UIViewController 就像一个菜单。所以我想通过点击我的 UIViewController 中的一个按钮来展示一个 UITabBarController。
但是在我的 UITabBarController 中,我需要为每个 ViewController 提供一个自己的 UINavigationController 本身。通过这样做: viewControllers = [UINavigationController(rootViewController: myVc()), ...] 对于我的 UITabBarController,我最终在我的 TableView 顶部有一个奇怪的导航栏(它在我的 ViewController 内部,由我的 TabBarController 呈现)+ Xcode 控制台中的一些警告:new observer <UINavigationController: 0x7fd87d846a00>, removing old observer <UINavigationController: 0x7fd87f02ba00>
导航栏如下所示:

所以问题是,我在另一个 UINavigationController 中添加了一个 UINavigationController(如果我删除了第二个 UINavigationController,一切都按预期工作)。不幸的是,我的 TabBarController 中的每个 (Table)ViewController 都需要一个自己的 UINavigationController,因为在第一个 (Table)ViewController 中,我将附加一个 UISearchController,如果我将此 UISearchController 附加到包含我的 TabBar 的 NavigationController,那么每个 ViewController TabBar 内部会得到这个 SearchController。 我该如何解决这个问题?
感谢您的每一次帮助!

【问题讨论】:

标签: ios swift uinavigationcontroller uisearchcontroller


【解决方案1】:

我相信无论您做什么,每个导航堆栈都应该只有一个UINavigationController。如果你使用更多,那么它会弄乱你的导航栏标题和导航链接。

您可以从 UITabBarController 开始,然后每个选项卡项都有一个 UINavigationController

试试这个解决方案:How to control multiple navigation controller in an iOS project

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-18
    • 1970-01-01
    • 2011-11-28
    相关资源
    最近更新 更多