0

我已搜索和搜索,但仍然无法找出这个问题! :-(UINavigation Controller和UITabbarController connumdrum

我在main.xib一个TabBarController是设置有五个viewControllers

我想获得第一的ViewController是一个导航控制器,这样如果第一个选项卡中选择我可以推及弹出意见眼帘

但对我的生活,我不能得到这个工作

我在我的应用程序委托didLaunch方法试过这样:?

UITabBarController *tabBarController = [[UITabBarController alloc] init]; 
tabBarController.delegate=self; 
FirstViewController *first = [[FirstViewController alloc] initWithNibName:@"FirstView" bundle:[NSBundle mainBundle]]; 
UINavigationController *firstNav = [[UINavigationController alloc] initWithRootViewController:first]; 
NSArray* controllers = [NSArray arrayWithObjects:firstNav, nil]; 
tabBarController.viewControllers = controllers; 
[window addSubview:tabBarController.view]; 

为什么我看到我的视图显示,但没有按钮出现在标签栏?

任何提示?日Thnx

回答

1

对于这一点,你必须添加以编程方式在TabBar中查看控制器。如下所示:

oFirstViewController.title = @"First View"; 
oFirstViewController.tabBarItem.image = [UIImage imageNamed:@"ico.png"]; 
UINavigationController *myNavigationController1 = [[UINavigationController alloc] initWithRootViewController:oFirstViewController]; 
tabBarController.viewControllers = [NSArray arrayWithObjects:myNavigationController1, myNavigationController2, myNavigationController3, myNavigationController4, nil]; 

这样,您必须将其余视图控制器添加到您的tabbar控制器。

希望它对你有帮助。

如有任何困难,请告知我。

+0

茶青!感谢芽;-)感谢所有谁回应,感谢它;-) – user7865437 2011-06-06 12:47:01

0

下面是解释链接如何设置的TabBar控制器和导航控制器
Link 1

希望它可以帮助你......

0
[first.tabBarItem initWithTitle:@"First" image:[UIImage imageNamed:@"first.png"] tag:0]; 
1

您的tabBarController只包含一个viewController。所以在tabBarController中只会有一个tabBarItem。由于只有一个viewController可用,所以tabBarItem将被默认选中,并且您无法更改选择。所以你不觉得有一个按钮。但它在那里。您可以设置标题图片viewController您将看到区别。

first.title = @"firstTab"; 
first.navigationItem.image = [UIImage imageNamed:@"firstTab.png"]; 
相关问题