UITabBarControllers和UINavigationControllers [英] UITabBarControllers and UINavigationControllers

查看:52
本文介绍了UITabBarControllers和UINavigationControllers的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有UITabBarController和四个不同选项卡的应用程序.这些选项卡中的三个是表格,您可以在每一行上单击以将其带到另一个视图.

I have an app with a UITabBarController and four different tabs. Three of these tabs are tables which you can click on each row and it would take you to another view.

我该如何在导航方面实现呢?我应该创建一个UITabBarController并将导航控制器作为选项卡(如图1所示)还是将View Controller作为选项卡(如图2所示),并且每个View Controller都具有自己的Navigation Controller属性吗?

How would I implement that in terms of navigation? Should I create a UITabBarController with Navigation Controllers as tabs (as shown in image 1) or with View Controllers as tabs (as shown in image 2) with each View Controller having its own Navigation Controller property?

图片1:

图片2:

我尝试了两种方法,但效果不佳且令人困惑.我想知道哪种方法更合适,所以我可以专注于该方法,然后看看为什么它不起作用.

I tried both but its not working well and its confusing. I'd like to know which is more appropriate so I can focus on that method and then see why it's not working.

推荐答案

您建议的第一种方法是 only 方法.视图控制器具有navigationController属性,但是仅当您的视图控制器当前包含在父导航控制器中时,它才会返回某些内容.

The first method you propose is the only method. View controllers have a navigationController property, but it will only return something if your view controller is currently contained within a parent navigation controller.

请注意:您应该有一个UITabBarController,其中包含导航控制器,对于要在其中具有导航层次结构的每个选项卡,一个导航控制器.

So to be clear: you should have a UITabBarController which contains your navigation controllers, one navigation controller for each tab that you want to have a navigation hierarchy in.

这篇关于UITabBarControllers和UINavigationControllers的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆