2

我推包含 uitabbarcontroller 的 Viewcontroller (viewcontroller 1) 有 3 个 viewcontroller (tabitem 1, tabitem 2, tabitem 3)。现在我希望每个 tabbaritem 在 uinavigationBar 上有不同的 UIBarbuttonitem。例如:在 tabitem 1 中有“1” barbuttonitem,在 tabitem 2 中有“2” barbuttonitem,在 tabitem 3 中没有 barbuttonitem。我该怎么做?

这是我创建 UItabbarcontroller 的代码:

 - (void)viewDidLoad
{
    [super viewDidLoad];
   // loginview = [[LoginTab alloc] init];
    // Do any additional setup after loading the view from its nib.
    self.tab=[[UITabBarController alloc]init];
    CGRect screenBounds = [[UIScreen mainScreen] bounds];
    if (screenBounds.size.height == 568)
    {
        // code for 4-inch screen
        //  LoginButton.frame = CGRectMake(0, 518, 80, 49);
        self.tab.view.frame = CGRectMake(0,0,320,568);
    }
    else if (screenBounds.size.height == 1024)
    {
        //code for ipad

    }
    else  if (screenBounds.size.height == 480)
    {
        // code for 3.5-inch screen
        //  LoginButton.frame = CGRectMake(0, 430, 80, 49);
        self.tab.view.frame = CGRectMake(0,0,320,480);
    }

    // FirstViewController
    UploadTab *uploadview=[[UploadTab alloc]initWithNibName:nil bundle:nil];

    uploadview.title=@"Uploading";
    uploadview.tabBarItem.image=[UIImage imageNamed:@"Uploading.png"];

    //SecondViewController
    ConvertTab *convertView=[[ConvertTab alloc]initWithNibName:nil bundle:nil];

    convertView.title=@"Convert";
    convertView.tabBarItem.image=[UIImage imageNamed:@"Convert.png"];

    //ThirdViewController
    CompletedTab *completedView=[[CompletedTab alloc]initWithNibName:nil bundle:nil];

    completedView.title=@"Completed";
    completedView.tabBarItem.image=[UIImage imageNamed:@"Completed.png"];

     self.tab.viewControllers=[NSArray arrayWithObjects:uploadview,convertView, completedView, nil];    

    [self.view addSubview:self.tab.view];
    //[self presentModalViewController:self.tab animated:NO]; // if use it, tabbar at bottom of screen correctly

}

另外,我使用上面的代码,标签栏显示位置不正确,它不在屏幕底部。请给我任何想法?非常感谢

4

0 回答 0