0

我在UITabBarController中有一個UINavigationController,我似乎無法得到一個推送viewController的tabBar隱藏。UITabBar不會隱藏

我使用下面的代碼隱藏:

,然後纔會慢慢推:

tpsv.hidesBottomBarWhenPushed = YES; tpsv.tabBarController.hidesBottomBarWhenPushed = YES;

viewWillAppear中:

self.tabBarController.tabBar.hidden = YES;

AppDelegate *del = (AppDelegate *)[[UIApplication sharedApplication] delegate];

[[[del tabController] tabBar]setHidden:YES];

但是以上都沒有工作。

如果你能告訴我如何解決這個問題,那就太好了。

回答

2
- (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]; 
} 
+0

那會去哪? – 2011-04-18 17:48:35

+0

你可以把這些函數放在一些全局文件中,你只需要調用隱藏函數來隱藏tabbarcontroller ..並顯示函數來顯示tabbarcontroller ...你可以調用這些方法 - [commonFunctions hideTabBar:self.tabbarcontroller]; – Saurabh 2011-04-18 17:50:35

+0

我試過它在viewController中,我不能隱藏,它也可以。 – 2011-04-18 17:52:02

4

你設置這一點,你推新視圖控制器之前:

MyViewController *myVC = [[[MyViewController alloc] init] autorelease]; 
myVC.hidesBottomBarWhenPushed = YES; 
[self.navigationController pushViewController:myVC animated:YES]; 

[編輯:評論重新用法]

只注意到你說你嘗試這個。不知道你在推動你的VC或配置它的情況下還在做什麼,但這沒問題。這就是我在應用程序中完成這件事的方式。

0

我面臨同樣的問題

myVC.hidesBottomBarWhenPushed = YES; 

它一點兒也不刪除標籤欄在隨後的意見。可能會被棄用。你不應該用setHidesBottomBarWhenPushed命令來面對這個問題。嘗試使用以下查看:

MyViewController *myVC = [[[MyViewController alloc] init] autorelease]; 
[myVC setHidesBottomBarWhenPushed:YES]; 
[self.navigationController pushViewController:myVC animated:YES];