2011-05-12 135 views
2

我正在使用基于视图的简单iPhone应用程序。 从应用程序的主屏幕,您可以导航到4个不同的视图。 其中一个视图由标签栏组成。 因为这不是我使用一个没有UITabController的解决方法的正常方法。如何隐藏基于视图/标签栏应用程序中的标签栏

要做到这一点,我利用了这个话题: https://discussions.apple.com/thread/2099944?start=0&tstart=0

而这个示例代码: http://pymbian.svn.sourceforge.net/svnroot/pymbian/stuff/testtab_raynewbie/Classes/

通过一些小的修改工作的。 只有当我想从标签视图返回到主视图时,我有最后一个错误,标签栏停留在屏幕底部。

我尝试了这里描述的几种方法。

myTabBar.hidden = YES 
hidesBottomBarWhenPushed = YES 

但似乎没有工作.... 我认为这个问题是在意见UI控制器的结构奇特的地方。因为现在结构看起来像这样。

MainViewController 
- ViewController with TabBar 
    - tab1viewcontroller 
    - tab2viewcontroller 
- other viewcontrollers 

和重返主视图在tab1viewcontroller,我不能做任何事情的TabBar完成。在所有其他观点,我回去这个代码:

-(IBAction) BackAction:(id)sender { 

mainControllerView = [[MainControllerView alloc] initWithNibName:@"MainControllerView" bundle:nil]; 
[self.view addSubview:mainControllerView.view]; 
[mainControllerView.view release]; 

} 

任何想法?

+0

我有同样的probem花花公子.U有什么解决方案?如果你知道任何事情PLZ解释谢谢。 –

回答

2

当您从前一个视图推送时,您需要隐藏标签栏。

LoginViewController *loginViewObj =[[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil]; 
loginViewObj.hidesBottomBarWhenPushed=YES; 

LoginViewController是在不需要标签栏的情况下推送的视图。 :)

在视图 - 控制器
0

尝试下面的代码,你要隐藏的TabBar

-(void)viewWillAppear:(BOOL)animated 
{ 
    [super viewWillAppear:YES]; 
    [self.tabBarController.view setFrame:CGRectMake(0, 0, 320, 560)]; 
} 

-(void)viewWillDisappear:(BOOL)animated 
{ 
    [super viewWillDisappear:YES]; 
    [self.tabBarController.view setFrame:CGRectMake(0, 0, 320, 480)]; 

} 
+0

这是一个蹩脚的方式来隐藏标签栏,你不应该以这种方式传播..遗憾的是投票。 –

相关问题