IOS 跳转页面的三种方式

1、改变window的根视图

self.window.RootViewController = VC;

2、模态弹出modal,(模态视图出现的场景一般是临时弹出的窗口,譬如:登陆窗口。)

[self presentViewController:nextVC  animated:YES completion:nil];//从当前界面到nextVC

[self dismissViewControllerAnimated:YES completion:nil];//从nextVC界面回去

这两个方法一般是一起使用,才能实现两个视图之间的来回切换

3 .用 UINavigationController push 进来和pop回去( 有导航栏控制器的情况下)

[self.navigationController pushViewController:nextVC animated:YES];//从当前界面到nextVC这个界面

[self.navigationController popViewControllerAnimated:YES];//nextVC这个界面回到上一界面[self.navigationController popToRootViewControllerAnimated:YES];//回到根视图界面

//self.navigationController.viewControllers 是一个数组里面存放所有之前push过来的界面,如果想要跳回到指定界面 只需要根据索引值取出响应的界面pop回去

QSTViewController *VC =self.navigationController.viewControllers[1];    [self.navigationController popToViewController:VC animated:YES];

猜你喜欢

转载自blog.csdn.net/qiangshuting/article/details/81407432