2012-11-01 145 views

回答

1

這樣做:

NSArray *arrControllers = self.tabBarController.viewControllers; 
for(UIViewController *viewController in arrControllers) 
{ 
    if([viewController isKIndOfClass:[UINavigationController class]]) 
    { 
    //NavigationController 
    UINavigationController *navCtrl = (UINavigationController *)viewController; 
    NSLog(@"%@",navCtrl.viewControllers); 
    } 
    else 
    { 
    // view controller 
    } 
} 
1

如果您要檢查這個當標籤被改變實施的UITabBarControllerDelegate回調:

-(void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController{ 
    //if you're using navigationController 
    UINavigationController *navC=(UINavigationController *)viewController; 
    NSArray *arrayVc=navC.viewControllers; 
    NSLog(@"%@",arrayVc); 
} 
相關問題