关于页面跳转的几种方法与比较
2015-10-20 15:04
435 查看
跳转1.storyboard内的简单的跳转
在页面1内拖入一个button,右击button,连线到要跳转的页面
跳转2.storyboard内使用控制器之间连线的segue来进行跳转
在页面1内右键拖线到要跳转的页面内,然后给中间的连线,设置一个identifier,
在跳转的时候使用 [self performSegueWithIdentifier:"identifier" sender:nil];
就实现跳转,并且还有prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender方式,实现跳转之间的传值
跳转3.storyboard内创建页面,使用导航栏跳转
根据控制器的identifier获取得到页面以及控制器,使用[self.navigationController pushViewController:vc animated:YES]方法进行跳转
tip:该方法跳转,跳转进入的控制器,会存在导航栏,使用self.navigationController的成员方法,
并且配合self.navigationController.viewControllers可以pop到任何想要跳转返回的界面。
用户可以点击返回,返回到上一个页面,方法4就无法做到跳转。
跳转4.storyboard内创建页面,使用show方法跳转
根据控制器的identifier获取得到页面以及控制器,使用[self presentViewController:vc animated:YES completion:nil]方法进行跳转
tip:该跳转方法,跳转进入的控制器内,不存在导航栏,需要使用[self dismissViewControllerAnimated:YES completion:nil]方法返回上一页
跳转5.XIB创建页面,使用show方法跳转
直接使用alloc,init方法或者new方法创建控制器,使用[self presentViewController:vc animated:YES completion:nil]方法进行跳转
跳转6.XIB创建页面,使用导航栏跳转
直接使用alloc,init方法或者new方法创建控制器,使用[self.navigationController pushViewController:vc animated:YES]方法进行跳转
tip:同跳转3
跳转7.纯代码创建页面,使用show方法跳转
直接使用alloc,init方法或者new方法创建控制器,使用[self presentViewController:vc animated:YES completion:nil]方法进行跳转
跳转8.纯代码创建页面,使用导航栏跳转
直接使用alloc,init方法或者new方法创建控制器,使用[self.navigationController pushViewController:vc animated:YES]方法进行跳转
tip:同跳转3
跳转9.tabbarController实现页面的跳转
通过各种方法创建好控制器之后,添加到数组内,并且赋值给self.tabbarController.viewControllers
在页面1内拖入一个button,右击button,连线到要跳转的页面
跳转2.storyboard内使用控制器之间连线的segue来进行跳转
在页面1内右键拖线到要跳转的页面内,然后给中间的连线,设置一个identifier,
在跳转的时候使用 [self performSegueWithIdentifier:"identifier" sender:nil];
就实现跳转,并且还有prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender方式,实现跳转之间的传值
跳转3.storyboard内创建页面,使用导航栏跳转
根据控制器的identifier获取得到页面以及控制器,使用[self.navigationController pushViewController:vc animated:YES]方法进行跳转
tip:该方法跳转,跳转进入的控制器,会存在导航栏,使用self.navigationController的成员方法,
并且配合self.navigationController.viewControllers可以pop到任何想要跳转返回的界面。
用户可以点击返回,返回到上一个页面,方法4就无法做到跳转。
跳转4.storyboard内创建页面,使用show方法跳转
根据控制器的identifier获取得到页面以及控制器,使用[self presentViewController:vc animated:YES completion:nil]方法进行跳转
tip:该跳转方法,跳转进入的控制器内,不存在导航栏,需要使用[self dismissViewControllerAnimated:YES completion:nil]方法返回上一页
跳转5.XIB创建页面,使用show方法跳转
直接使用alloc,init方法或者new方法创建控制器,使用[self presentViewController:vc animated:YES completion:nil]方法进行跳转
跳转6.XIB创建页面,使用导航栏跳转
直接使用alloc,init方法或者new方法创建控制器,使用[self.navigationController pushViewController:vc animated:YES]方法进行跳转
tip:同跳转3
跳转7.纯代码创建页面,使用show方法跳转
直接使用alloc,init方法或者new方法创建控制器,使用[self presentViewController:vc animated:YES completion:nil]方法进行跳转
跳转8.纯代码创建页面,使用导航栏跳转
直接使用alloc,init方法或者new方法创建控制器,使用[self.navigationController pushViewController:vc animated:YES]方法进行跳转
tip:同跳转3
跳转9.tabbarController实现页面的跳转
通过各种方法创建好控制器之后,添加到数组内,并且赋值给self.tabbarController.viewControllers
相关文章推荐
- DPM 2012 SP1恢复Exchange2013单用户邮箱
- Android 监听scrollview滚动实现ToolBar显示和隐藏的效果
- java 生成随机密码
- hdfs文件系统api操作
- EHCache使用
- 151018的测试总结
- MongoDB数据库用户名和密码的设置
- DELPHI删除记录文件
- 遍历HashMap的最佳方法
- Docker 会取代虚拟机吗?
- 创建 userSettings/Microsoft.SqlServer.Configuration.LandingPage.Properties.Settings 的
- bzoj3262: 陌上花开
- 小涛涛的计算器
- 替代mmm方案的mariadb galera cluster和percona xtradb cluster的简介
- Cocos2d提供的字体!共57种(有对照的字体图)
- 如何解决android模拟器慢的问题
- Android基础:shape的基本用法
- Linux服务器技术收集
- 用矩阵旋转相机
- Android应用(测试/正式)服务器端接口切换方法