iOS界面之间的跳转方式

来源:互联网 发布:js新手可以做的小游戏 编辑:程序博客网 时间:2024/05/16 10:58

iOS界面之间的跳转方式基本有3种。
1、改变window的根视图

  [self.window setRootViewController:VC];

2、模态弹出

     [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回去       MainViewController *MainVC =self.navigationController.viewControllers[1];    [self.navigationController popToViewController:MainVC animated:YES];
0 0
原创粉丝点击