②核心代码展示:
/** 在C页面的DisMiss方法里面添加一下代码(iOS6.0+) */if ([self respondsToSelector:@selector(presentingViewController)]){[self.presentingViewController.presentingViewController dismissViewControllerAnimated:YES completion:nil];}else {[self.parentViewController.parentViewController dismissViewControllerAnimated:YES completion:nil];}(二)在模态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];以上所述是小编给大家介绍的iOS中模态Model视图跳转和Push视图跳转的需求实现方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!