何时重用导航控制器?

发布于 2024-11-27 02:38:18 字数 104 浏览 1 评论 0原文

我正在尝试开发一个具有带有 5 个栏项目的选项卡栏控制器的应用程序。 所有项目都需要导航控制器。 我只是想知道是否可以为所有项目重用相同的导航控制器。 执行此操作是否有任何限制或需要注意的事项?

I'm trying to develop an app having a tab bar controller with 5 bar items.
All of the items need navigation controllers.
I just wanted to know whether it is possible to reuse the same navigation controller for all the items.
Are there any restrictions or things I need to keep in mind to do this?

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

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

发布评论

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

评论(2

甜`诱少女 2024-12-04 02:38:18

如果您需要的话,UITabBarController 中的每个选项卡都应该有自己的 UINavigationController。您将 UIViewController 推入或弹出堆栈,每个 UINavigationController 都有自己的堆栈。由于其他选项卡中的 UIViewController 与当前选项卡中的导航流无关,因此每个选项卡都应该有自己的 UINavigationController。

Every tab in a UITabBarController should have its own UINavigationController, if you're in need of one that is. You push and pop UIViewControllers onto/off a stack and every UINavigationController has its own stack. Since the UIViewControllers from your other tabs have nothing to do with the navigation flow from the current tab, each tab should have its own UINavigationController.

记忆之渊 2024-12-04 02:38:18

我想我最初可能在这里误解了您的问题...导航控制器实际上可以很好地重复使用我认为...我建议在更改选项卡时发布并创建一个新的选项卡(如果这在应用程序中有意义的话)。您可以在 appDelegate 中提供对它的引用,以便可以从每个视图控制器轻松访问它。

原始回复如下,以防我仍然误解它:S

分离完全取决于您,但为了代码清晰起见,最好将每个视图控制器分开。由于在控制器中可以找到很多代码,因此最好将尽可能多的代码分离出来。您可以使用相同的控制器,但在单击每个项目时更改它的视图属性,但它并没有真正节省太多,并且会使代码更难维护...

I think I may have misinterpreted your question originally here... Navigation Controllers actually fine to re-use I think... I'd recommend release and creating a new on when the tab is changed if that makes sense within the application. You could give a reference to it in your appDelegate so it's easily accessible from each view controller.

Original reply follows in case I'm misinterpreting it still :S

The separation is entirely up to you, but for code clarity it's nice to have each viewcontroller separate. As a lot of the code will be found in your controller it's quite nice to separate out as much as possible. You can use the same controller, but change it's view property when each item is clicked, but it doesn't really save much and wil make for harder to maintain code...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文