這裏是我的一段代碼,但這樣,當我推動第三級視圖控制器時,tabbar不會顯示。UINavigationController,如何在第二級viewController中隱藏tabbar然後在第三級viewController中顯示tabbar
//at first level
SecondLevelViewController *_2vc = [[SecondLevelViewController alloc]initWithNibName:@"SecondLevelViewController" bundle:nil];
_2vc.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:_2vc animated:YES];
//at second level
ThirdLevelViewController *_3vc = [[ThirdLevelViewController alloc]initWithNibName:@"ThirdLevelViewController" bundle:nil];
_3vc.hidesBottomBarWhenPushed = NO;
[self.navigationController pushViewController:_3vc animated:YES];
它的工作原理。但我不知道爲什麼在推動第三級視圖控制器時將hidesBottomBarWhenPushed屬性設置爲NO不起作用? –
我假設hidesBottomBarWhenPushed是一個布爾變量不?如果它只是一個布爾變量,你不能指望它自己隱藏/顯示視圖。您需要在您的視圖控制器中的某處實現隱藏/顯示代碼。在這個例子中,我在viewWillAppear方法中設置了隱藏/顯示代碼。 –