我想在UIViewControllers
中的tabbaritem的特定索引处获取UINavigationController
,即UITabBarController
堆栈的列表。
请详细说明..!
请大家一起携手
答案 0 :(得分:1)
如果要在更改选项卡时检查此项,请实施UITabBarControllerDelegate的回调:
-(void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController{
//if you're using navigationController
UINavigationController *navC=(UINavigationController *)viewController;
NSArray *arrayVc=navC.viewControllers;
NSLog(@"%@",arrayVc);
}
答案 1 :(得分: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
}
}