遍历控制器
- (void)backToRootVCClickBtn:(UIBarButtonItem *)item
{
for (UIViewController *temp in self.navigationController.viewControllers) {
if ([temp isKindOfClass:[BookPageViewController class]]) {
[self.navigationController popToViewController:temp animated:YES];}
}
设置当前的index
- (void)backToRootVCClickBtn:(UIBarButtonItem *)item
{
int index = (int)[[self.navigationController viewControllers]indexOfObject:self];
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:(index-2)] animated:YES];
}
当前导航控制下的所以控制器,遍历,然后将
- (void)backToRootVCClickBtn:(UIBarButtonItem *)item
{
UINavigationController *navigationVC = self.navigationController;
NSMutableArray *viewControllers = [[NSMutableArray alloc] init];
// 遍历导航控制器中的控制器
for (UIViewController *vc in navigationVC.viewControllers) {
[viewControllers addObject:vc];
// BookPageViewController就是你需要返回到指定的控制器名称,这里我需要跳转到BookPageViewController这个控制器
if ([vc isKindOfClass:[BookPageViewController class]]) {
break;
}
if ([vc isKindOfClass:[MyOrderViewController class]])
{
[[NSNotificationCenter defaultCenter] postNotificationName:@"NSNoticeResultForOrder" object:self userInfo:nil];
break;
}
// 把控制器重新添加到导航控制器
[navigationVC setViewControllers:viewControllers animated:YES];
}
}
但是tabBar颜色不能指定条状 (系统的可以),自己也 需要看自己给的方法了,可以发送个通知,但是通知一定要销毁
网友评论