2012-03-16 155 views
0

早上好,我試圖隱藏一個UITabBarItem,在閱讀了很多帖子後,我越來越瘋狂....我可以正確地獲取tabItem,但它不會隱藏。我在故事板中設置我的TabBar。UITabBarItem顯示/隱藏

這裏是我的3個選項我試過作品code..none ...

任何幫助會,如果你正在使用的Xcode 4.x的理解

@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; 
} 

回答

0

嘗試去做選擇你想要嵌入到tabBarController中的UIviews,然後轉到編輯器>嵌入>選項卡欄控制器。我這樣做,它效果更好。

+0

感謝ClOck,這是我做到的方式,但UITabBarItem抵制隱藏.... – Christian 2012-03-19 07:13:10