Ipad 将UITabBarItems添加到UITabBar

Ipad 将UITabBarItems添加到UITabBar,ipad,uitabbarcontroller,uitabbaritem,Ipad,Uitabbarcontroller,Uitabbaritem,我希望任何人都能向我解释如何做到这一点: 我有一个TabBar和两个Tabbaritem,如何将这些项目附加到TabBar。 我不是通过IB来做这件事的,因为TabBar只适合屏幕的左侧,因为项目应该在左侧 这就是我构建它们的方式: tabBarController = [[UITabBarController alloc] initWithNibName:nil bundle:nil]; tabBarController2 = [[UITabBarController alloc] initW

我希望任何人都能向我解释如何做到这一点:

我有一个TabBar和两个Tabbaritem,如何将这些项目附加到TabBar。 我不是通过IB来做这件事的,因为TabBar只适合屏幕的左侧,因为项目应该在左侧

这就是我构建它们的方式:

tabBarController = [[UITabBarController alloc] initWithNibName:nil bundle:nil];
tabBarController2 = [[UITabBarController alloc] initWithNibName:nil bundle:nil];

tabBarController.tabBar.frame = CGRectMake(0, 974, 384, 50);    
tabBarController2.tabBar.frame = CGRectMake(384, 974, 384, 50);

UITabBarItem *tbi1 = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemMostViewed tag:0];
UITabBarItem *tbi2 = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemMostViewed tag:1];

不能直接在选项卡栏中设置选项卡栏项目。而是为选项卡栏控制器包含的每个视图控制器的
tabBarItem
属性指定一个选项卡栏项。然后,将视图控制器添加到选项卡栏控制器时,选项卡栏控制器将为您管理选项卡栏项目的显示

UITabBarController * tabBarController = [[UITabBarController alloc] init];

UIViewController * viewController1 = [[YourViewController alloc] init];
UIViewController * viewController2 = [[YourOtherViewController alloc] init];

viewController1.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemMostViewed tag:0];
viewController2.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemMostViewed tag:1];

tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, nil];

我已经试过了,但没有成功,但那是我的第二个TabBar造成的。错误是我认为当我收缩TabBar时,它只会影响TabBar。现在我作弊了,我用空白按钮填充了一面并禁用了它们,现在我有了单独的标签栏。。。。。