我有导航栏和标签栏的视图.我想要发生的是隐藏某个视图上的标签栏,并在用户更改视图时再次显示标签栏.
我看到一段用于隐藏标签栏的代码:
-(void)makeTabBarHidden:(BOOL)hide
{
// Custom code to hide TabBar
if ( [tabBarController.view.subviews count] < 2 ) {
return;
}
UIView *contentView;
if ( [[tabBarController.view.subviews objectAtIndex:0] isKindOfClass:[UITabBar class]] ) {
contentView = [tabBarController.view.subviews objectAtIndex:1];
} else {
contentView = [tabBarController.view.subviews objectAtIndex:0];
}
if (hide) {
contentView.frame = tabBarController.view.bounds;
}
else {
contentView.frame = CGRectMake(tabBarController.view.bounds.origin.x,
tabBarController.view.bounds.origin.y,
tabBarController.view.bounds.size.width,
tabBarController.view.bounds.size.height - tabBarController.tabBar.frame.size.height);
}
tabBarController.tabBar.hidden = hide;
}
Run Code Online (Sandbox Code Playgroud)
来自:http://nickwaynik.com/iphone/hide-tabbar-in-an-ios-app/
我在视图中调用它,我希望隐藏标签栏
[self makeTabBarHidden:YES];
Run Code Online (Sandbox Code Playgroud)
当我在该视图上显示/隐藏它时,它工作正常但当我导航回到上一个视图时,那里的标签栏也是隐藏的.我试着打电话给在视图中的该功能viewDidUnload,viewWillDisappear,viewDidDisappear功能,但没有任何反应.当函数被调用在前面视图的情况也是如此viewDidLoad, …