是否可以从另一个UINavigationController呈现UINavigationController?

问题描述 投票:-1回答:1

我有一个UINavigationController,其中包含一个UIViewController。 UIViewController的作用类似于菜单。因此,我想通过单击UIViewController中的按钮来呈现一个UITabBarController。但是在我的UITabBarController内部,我需要为每个ViewController自己拥有一个UINavigationController。通过执行以下操作: viewControllers = [UINavigationController(rootViewController: myVc()), ...] 对于我的UITabBarController,我最终在TableView(位于ViewController的内部,由TabBarController呈现)的顶部有一个奇怪的navigationBar + Xcode控制台中的一些警告:new observer <UINavigationController: 0x7fd87d846a00>, removing old observer <UINavigationController: 0x7fd87f02ba00>navigationBar看起来像这样:enter image description here所以问题是,我在另一个UINavigationController内添加了一个UINavigationController(如果我删除了第二个UINavigationController,一切都会按预期工作)。不幸的是,我在TabBarController中的每个(Table)ViewController都需要一个自己的UINavigationController,因为在第一个(Table)ViewController中,我将附加一个UISearchController,如果我将此UISearchController附加到保存我的TabBar的NavigationController上,那么每个ViewController在TabBar内将获得此SearchController。我该如何解决这个问题?感谢您的帮助!

ios swift uinavigationcontroller uisearchcontroller
1个回答
0
投票

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

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

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

© www.soinside.com 2019 - 2024. All rights reserved.