2

uitabbarcontroller を含む 3 つのビューコントローラー (tabitem 1、tabitem 2、tabitem 3) を持つ Viewcontroller (viewcontroller 1) をプッシュします。例: 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