+ (void)removeController:(UIViewController *)vc {
NSArray* tempVCA = [vc.navigationController viewControllers];
for(UIViewController *tempVC in tempVCA) {
if([tempVC isKindOfClass:[vc class]]) {
[tempVC removeFromParentViewController];
}
}
}
removeFromParentViewController 这个方法会有一些问题,虽然将控制器移除了,但是返回的依然是这个控制器的导航栏
所以采用,break要加,因为不加可能会有些问题
+ (void)removeController:(UIViewController *)vc {
NSMutableArray* tempVCA = [NSMutableArray arrayWithArray:[vc.navigationController viewControllers]];
for(UIViewController *tempVC in tempVCA) {
if([tempVC isKindOfClass:[vc class]]) {
[tempVCA removeObject:tempVC];
break;
}
}
vc.navigationController.viewControllers = tempVCA;
}
网友评论