本文给大家分享下模态Model视图跳转和Push视图跳转的需求实现。
开前自打小广告:一键合成APP引导页,包含不同状态下的引导页操作方式,同时支持动态图片引导页和静态图片引导页以及视频引导页;GitHub地址: https://github.com/dingding3w/DHGuidePageHUD (多多Star,多多支持);
(一)连续两次模态Model视图之后,然后返回首页(A -> B -> C -> A)
①效果图展示:
②核心代码展示:
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)
①效果图展示:
②核心代码展示:
UINavigationController *ANavigationController = [[UINavigationController alloc] initWithRootViewController:[[BViewController alloc] init]];
[self presentViewController:ANavigationController animated:YES completion:nil];
#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];
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
以上所述是小编给大家介绍的iOS中模态Model视图跳转和Push视图跳转的需求实现方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对考高分网网站的支持!



