何时重用导航控制器?
我正在尝试开发一个具有带有 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您需要的话,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.
我想我最初可能在这里误解了您的问题...导航控制器实际上可以很好地重复使用我认为...我建议在更改选项卡时发布并创建一个新的选项卡(如果这在应用程序中有意义的话)。您可以在 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