iOS初学者日记----出入栈跳转和模态跳转

2018-08-21  本文已影响0人  I牧神的午后I
RegisterViewController *registerViewController = [RegisterViewController new];
[self.NavigationController pushViewController:registerViewController animated:YES];
//返回到根视图
[self.navigationController popToRootViewControllerAnimated:YES];
//返回到指定视图
for (UIViewController *controller in self.navigationController.viewControllers) {
    if ([controller isKindOfClass:[LoginViewController class]]) {
       [self.navigationController popToViewController:controller animated:YES];
    }
}

这种采用压栈和出栈进行页面跳转的方式,就是出入栈跳转。

SelectViewController * selectViewController = [[SelectViewController alloc] init];        
//把当前控制器作为背景
self.definesPresentationContext = YES;
//设置模态视图弹出样式
selectViewController.modalPresentationStyle = UIModalPresentationOverFullScreen;
[self presentViewController:selectViewController animated:YES completion:nil];
[self dismissViewControllerAnimated:YES completion:NULL];

模态跳转主要在:收集用户输入信息,临时展示一些内容,显示一个新的view层级等时候会用到。

上一篇 下一篇

猜你喜欢

热点阅读