2011-02-16 84 views
2

加载标签栏在第二视图

我一直在寻找一个解决这个问题的很多天,但不能似乎找到了答案。在iphone中我想要一个登录视图,作为第一个视图,然后导致一个标签栏视图。我如何实现这个?

在此先感谢

回答

0

将您的登录视图转换为模式视图,正如Dirty Henry所建议的,从UI设计角度来看可能是一个好主意,但如果您只是想将UITabBar添加到视图中,则可以在界面构建器中进行。只需将标签栏放在您想要的视图中,并将该视图的控制器设置为标签栏的代表。您必须自行响应选项卡栏的选项,但这并不难。

+0

嘿,谢谢,帮助。 –

0

试试这个

self.hidesBottomBarWhenPushed = YES; 

启动基于的TabBar应用程序,并尝试这viewDidLoad中。

0
- (void)viewDidLoad { 
[super viewDidLoad]; 
NSLog(@"Tabbar created"); 


tab=[[UITabBarController alloc]init]; 
tab.view.frame=CGRectMake(0, 0, 320,460); 

tab.delegate=self; 

BSheepViewController *home=[[BSheepViewController alloc]init]; 
home.tabBarItem.image=[UIImage imageNamed:@"home.png"]; 
[email protected]"Home"; 
UINavigationController *HomeNav=[[[UINavigationController alloc]init]autorelease];; 
[HomeNav pushViewController:home animated:YES]; 
    //UINavigationController *HomeNav=[[[UINavigationController alloc]initWithRootViewController:home]autorelease]; 
    //[self.navigationController pushViewController:home animated:YES]; 
[home release]; 

    tab.viewControllers = [NSArray arrayWithObjects:HomeNav, nil]; 

tab.selectedIndex=bval; 

[self.navigationController pushViewController:tab animated:YES]; 

} 

在TabBar控制器中使用这种类型的代码。在您登录查看U应该写这样

-(void)viewWillAppear:(BOOL)animated{ 

[self performSelector:@selector(fade)]; 
NSLog(@"%@",self.navigationController); 

[self.navigationController setNavigationBarHidden:YES]; 

button1 = [UIButton buttonWithType:UIButtonTypeCustom]; 
button1.showsTouchWhenHighlighted=YES; 
button1.frame = CGRectMake(30,60,48,48); 
[button1 addTarget:self action:@selector(Articles:) forControlEvents:UIControlEventTouchUpInside]; 
// [button1 setBackgroundImage:b1 forState:UIControlStateNormal]; 

[image2 addSubview:button1]; 
[image2 bringSubviewToFront:button1]; 
[image2 setUserInteractionEnabled:YES]; 
button1.tag=1; 

    } 

-(void)Articles:(id)sender{ 
NSLog(@"Articles fired"); 
TabBar *tab=[[TabBar alloc]initWithNibName:@"TabBar" bundle:nil]; 
tab.bval=button1.tag; 
[self.navigationController pushViewController:tab animated:YES]; 
[tab release]; 
    } 

ü应该在登录查看使用导航控制器把你的TabBar视图,在控制器的TabBar你也应该导航控制器。它为我工作。让我知道你是否还没有找到。

相关问题