[英]UITabBar wont hide
我在UITabBarController中有一個UINavigationController,但似乎無法隱藏被推入的viewController的tabBar。
我正在使用以下代碼將其隱藏:
在推入之前:
tpsv.hidesBottomBarWhenPushed = YES;
tpsv.tabBarController.hidesBottomBarWhenPushed = YES;
viewWillAppear:
self.tabBarController.tabBar.hidden = YES;
AppDelegate *del = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[[[del tabController] tabBar]setHidden:YES];
但以上工作均無效。
如果您能告訴我如何解決此問題,那就太好了。
您在推送新的視圖控制器之前進行了設置:
MyViewController *myVC = [[[MyViewController alloc] init] autorelease];
myVC.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:myVC animated:YES];
[編輯:評論重用]
只是注意到您說您嘗試過此操作。 不知道在推送或配置VC的情況下您還要做什么,但這確實可以正常工作。 這就是我在應用程序中執行此操作的方式。
- (void) hideTabBar:(UITabBarController *) tabbarcontroller {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
for(UIView *view in tabbarcontroller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, 480, view.frame.size.width, view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 480)];
}
}
[UIView commitAnimations];
}
- (void) showTabBar:(UITabBarController *) tabbarcontroller {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
for(UIView *view in tabbarcontroller.view.subviews)
{
NSLog(@"%@", view);
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, 431, view.frame.size.width, view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 431)];
}
}
[UIView commitAnimations];
}
我遇到了同樣的問題
myVC.hidesBottomBarWhenPushed = YES;
它不會在后續視圖中刪除選項卡欄。 可能已經過時了。 使用setHidesBottomBarWhenPushed:命令不應該遇到此問題。 嘗試使用以下視圖:
MyViewController *myVC = [[[MyViewController alloc] init] autorelease];
[myVC setHidesBottomBarWhenPushed:YES];
[self.navigationController pushViewController:myVC animated:YES];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.