UITabBarController中的隐藏UINavigationController [英] Hidden UINavigationController inside UITabBarController

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

问题描述

我有一个应用程序与 UINavigationController 中的每个内部的 UIViewController

I have an application with 5 UIViewControllers each inside a corresponding UINavigationController, all tucked inside a UITabBarController that displays 5 tabs at the bottom of the screen.

我要显示另一个 UIViewController

I want to display another UIViewController (inside a UINavigationController) when a dialog button is pressed.

编程加载和卸载;即它不应该出现在标签栏中。

This view should only be loaded and unloaded programatically; i.e. it should not appear in the tab bar. However, I want the tab bar to be visible always.

如果我将 [UINavigationController视图] 添加到 [self window] 覆盖 UITabBar 。如果我将它添加到任何其他层, UINavigationController 添加了它对状态栏的补偿,因此比预期的进一步下降。

If I add the [UINavigationController view] to [self window] the UITabBar is covered. If I add it to any other layer, the UINavigationController adds on the compensation it has for the status bar so appears further down than expected.

一个解决方案是让其他人将 UINavigationController 添加到 UITabBar tabBarItem 已隐藏。然后我可以使用 tabBar s selectedIndex 属性显示它并隐藏它。

A solution would be to have the 6th UINavigationController added to the UITabBar with the others, but with its tabBarItem hidden. Then I can show it and hide it using the tabBars selectedIndex property.

通过 UIViewController 访问 tabBarItem 没有明显的方法。

Accessing the tabBarItem through the UIViewController shows no obvious way of doing this.

@wisequark,我认为你完全误解了,你几乎重写了我的应用程序的架构。但是我有一个单独的导航控制器为每个视图,因为它们是相互排斥的,没有概念向下钻取。

@wisequark, I think you completely misunderstood and you have almost rewritten the architecture of my application. However I have a separate navigation controller for each view as they are mutually exclusive and there is no concept of "drilling down".

@Kendall,这是我期望的将必须做 - 具有模态视图显示与隐藏按钮带回正常的界面。

@Kendall, This is what I expect I will have to do - have the modal view appear with a hide button to bring back the normal interface. But it would be nice to keep the tab bar always visible, so I was just wondering if anyone knew of a way.

推荐答案

这是一个很好的选择,好吧,它听起来像你真正想做的是提供一个模态视图与选项卡栏仍然可见。您可以将视图添加为标签栏控制器视图的子视图。标签栏的视图很奇怪,不是标签栏本身,而是包含标签栏和所选项目视图的视图。

Well, it sounds like what you really want to do is present a modal view with the tab bar still visible. You could add your view as a subview of the tab bar controller's view. The tab bar's view is, oddly enough, not the tab bar itself but rather a view containing the tab bar and the selected item's view.

或者,您可以尝试调用presentModalViewController :animated:使用所选标签(即[tabBarController.selectedViewController presentModalViewController:animated:])作为接收者,而不是标签栏。

Alternatively, you could try calling presentModalViewController:animated: with the selected tab (i.e. [tabBarController.selectedViewController presentModalViewController:animated:]) as the receiver instead of the tab bar. I seem to recall doing this once (quite by accident) and the tab bar remained visible.

还有一个想法:因为你的五个视图控制器中的每一个都是一个UINavigationController,你可以总是pushViewController:animated:到所选的视图控制器,然后隐藏后退按钮。您的视图将只显示没有动画。但是,当用户切换到另一个选项卡时,您需要记住将视图控制器从堆栈中弹出。这可能需要更多的工作。

One more thought: since each of your five view controllers is a UINavigationController, you could always pushViewController:animated: onto the selected view controller, then hide the back button. Your view will just appear without animation. But you'll need to remember to pop your view controller off the stack whenever the user switches to another tab. That might take a bit more work.

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

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