-hidesBottomBarWhenPushed在Nav Controller中使用时导致问题

时间:2014-01-06 17:12:57

标签: ios objective-c uiviewcontroller uitabbarcontroller

使用-hidesBottomBarWhenPushed属性时,我遇到了奇怪的视图控制器问题。这是一个仅限iOS 7的项目。使用Xcode 5.whatever是最新的。没有贝塔。

有几个问题,但我认为它们都围绕着同样的问题。以下是我的不同用例。

两个用例都以相同的布局开头。 UITabBarController(2个标签) - > UINavigationController(Tab1) - > Tab2(例如不需要) - >在我的应用程序窗口中设置为rootViewController。

用例1:

ViewController1 - Has navigation controller and tableview with content. Push a view controller that does not need the tab bar (uses toolbar with custom content).
ViewController2 - Tab bar is not showing, things look great so far. Now I need to push another view controller that needs the tab bar again.
ViewController3 - Tab bar is showing, things are still good to go. One more level to go, tab bar still needs to show.
ViewController4 - Tab bar is missing. Not good. This sucks, lets back up.
ViewController3 - Tab bar is now gone here too. View takes up full space, that is good, but no tab bar. Back we go.
ViewController2 - What the eff? My toolbar is shaded and can't be selected, and the view is sized like there is a tab bar there. I can scroll content and see where it thinks the view ends. This view is toast, back to home.
ViewController1 - Everything is back to normal. Tab bar showing no problem. I can drill back in with no issues going in, but coming back, everything is hosed pretty bad.

用例2:

我们可以跳过视图并获得类似的结果。

ViewController1 - Same as Use Case 1. Our home view, where everything is working and looks great.
ViewController3 - Lets skip the toolbar view and keep our tab bar in place. No sweat. Tab bar shows up fine. Looks good, lets drill in one more level.
ViewController4 - The hell? Tab bar is here, but it looks shaded or selected. Content is offset up from the tab bar, it doesn't line up with the tab bar. About the same height as the tab bar. If we toggle tabs, the tab bar loses its shaded state. Come back to same screwed up view... looks fine now. The table view here is now nested perfectly on top of the tab bar. I give up!!
ViewController3 - The tab bar here looks fine at least. Whew! One less thing to fix.
ViewController1 - Home still looks good. Please don't ever leave me home view.

这些是我采取的步骤。现在我是如何推动这些观点的。

ViewController1 - 大部分是繁重的举动。由于其他问题的示例和修正,在将视图推出门之前设置-hidesBottomBarWhenPushed属性。

所有视图控制器都在init期间设置了属性,self.hidesTabBar;是隐藏它,没有显示它。

ViewController2 alloc/init; // normal init stuffs
// set current view property to the property on next views property (set in init of view) 
[self setHidesBottomBarWhenPushed:ViewController2.hidesTabBar];
[self.navigationController pushViewController:ViewController2 animated:YES];
// set back after pushing to what the current view needs to be at
[self setHidesBottomBarWhenPushed:self.hidesTabBar];

此方法继续将所有视图推送到导航堆栈。基本上,在我推送之前,我将当前视图-hidesBottomBarWhenPushed属性设置为与我即将推送的视图相同。在我推后,我将其设置回到我推动之前的状态。

我已经尝试过设置这个的每一个组合,我最终遇到了问题。我需要能够控制标签栏何时显示。有些情况下它总是会出现的。一些它将显示/隐藏/显示/显示,以及它们之间的每个组合。唯一的常量是它将始终显示在导航堆栈的根/第一个视图中。之后,这一切都取决于用户所采用的路径。帮助!

1 个答案:

答案 0 :(得分:0)

在提交雷达之后,似乎Apple已经承认这是iOS 7中的一个错误。他们报告说它已在iOS 7.1b4中修复。我也确认这也是在该版本中修复的。

相关问题