我正在编辑我的问题,我已经按步骤添加了下面的选项卡:
FirstViewController *obj_FirstViewController = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
SecondViewController *obj_SecondViewController = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
ThirdViewController *obj_ThirdViewController = [[ThirdViewController alloc] initWithNibName:@"ThirdViewController" bundle:nil];
navigation1 = [[UINavigationController alloc] initWithRootViewController:obj_FirstViewController];
navigation2 = [[UINavigationController alloc] initWithRootViewController:obj_SecondViewController];
navigation3 = [[UINavigationController alloc] initWithRootViewController:obj_ThirdViewController];
MainTabBar = [[UITabBarController alloc] init];
MainTabBar.delegate=self;
[MainTabBar setViewControllers:[NSArray arrayWithObjects:navigation1,navigation2,navigation3,nil]];
MainTabBar.view.frame=self.view.frame;
MainTabBar.selectedIndex=0;
[self.view addSubview:MainTabBar.view]通过在(ViewDidLoad)中写入这个选项卡,我在我的viewcontroller.But中得到了3个选项卡,问题是我想将该选项卡的名称设置为
我试着写了以下代码:
”
但这是行不通的-谁能帮我如何通过编程完成这一工作?在哪里写行,以便在我的选项卡栏中得到这个3名
发布于 2011-05-18 09:35:38
我就是这么做的
1)我为每个选项卡添加了视图控制器,并为选项卡视图控制器类创建了一个方法:-(void)updateContentsWithViewController:(UIViewController *)insideViewController
当按下选项卡按钮时,将调用该方法。
3)这是交换的代码
- (void)updateContentsWithViewController:(UIViewController *)insideViewController {
//internalViewController is the viewController which you change
[internalViewController.view removeFromSuperview];
[internalViewController release];
internalViewController = [insideViewController retain];
navController = [[UINavigationController alloc] initWithRootViewController:insideViewController];
[navController setNavigationBarHidden:YES];
[navController.view setFrame:CGRectMake(0, 0, 320, 348)];
//frame I needed in my app .. can be changed
[self.internalView addSubview: navController.view];
//navController is the property for the navigationController
[self.view sendSubviewToBack: self.internalView];}
发布于 2011-05-18 09:21:20
它可能将tabBar添加到单独的视图控制器中,这将类似于rootview控制器,然后在根视图控制器的viewDidLoad中将创建的选项卡对象分配给一个应用程序委托tabbar声明的...then,仅用于其他导航的应用程序委托选项卡。
https://stackoverflow.com/questions/6042247
复制相似问题