如何以编程方式删除在xcode中创建的选项卡栏项

时间:2014-09-19 14:35:26

标签: ios objective-c xcode

我的应用程序是一个基于标签栏的应用程序,有5个标签项关系ship segue to view controllers。我想构建3个不同大小的视图控制器(iPhone 5,6和6+)。我的想法是在xcode图形中绑定3个不同的视图控制器,并在运行时删除特定iPhone不需要的两个视图控制器。

UITabBar *oldbar = self.tabBarController.tabBar;
UITabBar *newbar = [[UITabBar alloc] initWithFrame:CGRectMake(0,0,oldbar.frame.size.width,oldbar.frame.size.height)];
NSMutableArray *olditems = [[oldbar items] mutableCopy];
[olditems removeObjectAtIndex:2];
[olditems removeObjectAtIndex:3];
NSArray *newitems = [[NSArray alloc] initWithArray:olditems];
[newbar setItems:newitems animated:false];
[oldbar addSubview:newbar];

问题是xcode显示“更多..”标签,因为在xcode中没有5个但是有7个标签项?

有没有更好的方法来编程我需要的东西?

0 个答案:

没有答案
相关问题