早上好,我正在试着隐藏一个UITabBarItem,在读了很多帖子后,我快疯了……我可以正确地获取tabItem,但是它不能隐藏。我在故事板中设置我的TabBar。
这是我尝试过的3个选项中的code..none。
任何帮助我们都将不胜感激。
@implementation unidaAppDelegate
@synthesize window = _window;
@synthesize tabBarController = _tabBarController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
self.tabBarController = [storyboard instantiateViewControllerWithIdentifier:@"myTab"];
NSMutableArray *tabs = [NSMutableArray arrayWithArray:self.tabBarController.viewControllers];
NSLog(@"Array:%@",tabs);
/*
OPTION 1
NSMutableArray *viewControllersCopy = [[self.tabBarController viewControllers] mutableCopy];
[viewControllersCopy removeObjectAtIndex:2];
NSArray *modifiedViewControllers = [[NSArray alloc] initWithArray:viewControllersCopy];
[self.tabBarController setViewControllers:modifiedViewControllers animated:NO];
OPTION 2
NSMutableArray *modifyMe = [[self.tabBarController.tabBar items] mutableCopy];
[modifyMe removeObjectAtIndex:2];
NSArray *newItems = [[NSArray alloc] initWithArray:modifyMe];
[self.tabBarController.tabBar setItems:newItems animated:true];
OPTION 3
NSLog(@"TabBarItem: %@",[[self.tabBarController.tabBar.items objectAtIndex:2] title]);
[[self.tabBarController.tabBar.items objectAtIndex:2] setEnabled:FALSE];
*/
sleep(1);
return YES;
}发布于 2012-03-16 20:12:55
如果你使用的是Xcode4.x,试着选择你想要嵌入到tabBarController中的UIviews,然后选择go to Editor>Embed in>标签栏控制器。我这样做,效果会更好。
https://stackoverflow.com/questions/9735825
复制相似问题