在新建的UINavigationController
控制器中遵循UINavigationControllerDelegate
,并实现其代理方法,具体如下:
1、设置代理:
- (void)viewDidLoad {
[super viewDidLoad];
self.delegate = self;
// Do any additional setup after loading the view.
}
2、实现代理方法:
#pragma -- UINavigationControllerDelegate
//解决pop到指定控制器tabBar重复的问题
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated{
for (UIView *tabBarView in self.tabBarController.tabBar.subviews) {
if ([tabBarView isKindOfClass:NSClassFromString(@"UITabBarButton")]) {
[tabBarView removeFromSuperview];
}
}
}```