1、在模态Model推出的视图中Push下一个带导航栏的视图,然后返回首页(A -> B ->C -> A)
核心代码展示:
/** 这里用到的核心处理办法是 */
/** 1.在A控制器模态Model推出B控制器的时候先给B控制器包装一个导航控制器 */
UINavigationController *ANavigationController = [[UINavigationController alloc] initWithRootViewController:[[BViewController alloc] init]];
[self presentViewController:ANavigationController animated:YES completion:nil];
/** 2.在B控制器遵守UINavigationControllerDelegate实现代理协议,隐藏当前控制器的导航栏 */
#pragma mark - UINavigationControllerDelegate
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
// 判断要显示的控制器是否是自身控制器
BOOL isShowMyController = [viewController isKindOfClass:[self class]];
[self.navigationController setNavigationBarHidden:isShowMyController animated:YES];
}
#pragma mark - Push出C控制器
[self.navigationController pushViewController:[[CViewController alloc] init] animated:YES];
/** 3.在C控制器里面可直接在返回按钮方法里DisMiss */
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
希望能够帮助你