UINavigationController 内的 UITabBarController 内的 UINavigationController
我的问题是我想要一个选项卡栏视图,其子视图控制器首先显示。在子视图控制器中,根据单击的控件,我要么想要 A)在选项卡栏视图中向下钻取(滑开子视图控制器),要么 B)在选项卡栏视图上向下钻取(滑开选项卡栏)视图控制器)。
我尝试通过将导航控制器包装在选项卡栏控制器的子视图控制器中(这样我可以使用方法 A 向下钻取)来解决这个问题,然后在选项卡栏控制器本身周围包装另一个导航控制器(这样我可以向下钻取)使用方法 B),因此得名。事情是这样的: 窗口-> UINavigationController-> UITabBarController ->; UINavigationController-> !
问题是我最终得到了两个导航栏:
两个导航栏 http://img527.imageshack.us/img527/240/problemc.png
有其他人遇到过这个问题吗?如果有,您是如何解决这个问题的? 谢谢!
My problem is that I want to have a tab bar view with its children view controllers shown first. In the children view controllers, depending on what controls are clicked, I either want to A) drill down within the tab bar view (swiping away the child view controller) or B) drill down over the tab bar view (swiping away the tab bar view controller).
I've tried solving this problem by wrapping a navigation controller within the children view controllers (so I can drill down using method A) of the tab bar controller and then wrapping another navigation controller around the tab bar controller itself (so I can drill down using method B), hence the title. So it goes:
Window -> UINavigationController -> UITabBarController -> UINavigationController -> child view controller
The problem is that I end up with two navigation bars:
two navigation bars!! http://img527.imageshack.us/img527/240/problemc.png
Has anyone else had this problem, and if so, how did you get around it?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在这种情况下,也许您可以简单地使用
UITabBar
并以编程方式管理其状态,而无需将选项卡栏控制器嵌套在另一个控制器中。In this case, perhaps you can simply use a
UITabBar
and programmatically manage its state, without nesting a tab bar controller inside another controller.如果您使用两个嵌套的 UINavigationController,我认为您无法解决拥有两个导航栏的问题。您可以为您不想显示其栏的控制器创建子类或方法 swizzle UINavigationController,并以某种方式阻止它出现或创建。您可能还可以相应地设置导航栏的不透明属性或隐藏属性,这也可能有效,但您可能需要进行一些奇特的 UIView 重新排列以防止出现空白。
这纯粹是猜测;我不知道这两种方法是否有效或如何有效,但如果我尝试这样做,这些想法就是我会开始的。
If you're using two nested UINavigationControllers I don't think you can work around having two nav bars. You may be able to subclass or method swizzle UINavigationController for the controller whose bar you don't want to show, and somehow prevent it from appearing or being created. You can probably also set the navigation bar's opaque property or hidden property accordingly which may also work, but you would probably need to do some fancy UIView rearranging to prevent empty gaps.
This is purely speculation; i don't know if either approach would work or how they would, but those ideas are what i would get started with were i trying to do this.
只需隐藏您不需要的栏即可,就像这样简单:
Just hide the bar you don't want, easy as this: