弹出新ViewController的方法
来源:互联网 发布:java gui编程教程 编辑:程序博客网 时间:2024/04/30 05:00
1.使用UINavigationController的pushViewController:animation方法
if (self.navigationController) { [self.navigationController pushViewController:newViewController animated:YES]; }
返回之前的视图:
[self.navigationController popViewControllerAnimated:flag];
ps:push以后会在navigation的left bar自动添加back按钮,它的响应方法就是返回。所以一般不需要写返回方法,点back按钮即可。
2.直接使用UIViewController的presentViewController:animation:completion方法
[self presentViewController:retrieveViewController animated:YES completion:nil];
返回之前的视图:
[self.presentingViewController dismissViewControllerAnimated:flag completion:completion];
3.addSubView
UINavigationController是导航控制器,如果pushViewController的话,会跳转到下一个ViewController,点返回会回到现在这个ViewController;
如果是addSubview的话,其实还是对当前的ViewController操作,只是在当前视图上面又“盖”住了一层视图,其实原来的画面在下面呢,看不到而已
另加一个
使用presentViewControllerAnimated方法从A->B->C,若想在C中直接返回A,则可这样实现:
C中返回事件:
然后在B中,
- //在viewdidload中:
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(back) name:@"backback" object:nil];
- -(void)back
- {
- [self dismissModalViewControllerAnimated:YES];
- }
0 0
- 弹出新ViewController的方法
- 在viewController“添加”viewController的方法
- 新弹出窗口的几种方法
- 弹出框调用一个新的方法
- ViewController生命周期的各个方法
- ViewController页面跳转的方法
- presentViewController 弹出半透明ViewController
- 设备翻转时viewController调用的方法
- ViewController响应显示相关的通知方法
- viewController中方法执行的时机
- viewcontroller页面间传值的几种方法
- 26.ViewController的生命周期及其方法介绍
- 完整获取当前ViewController的方法
- java Swing 弹出新对话框的方法,以及关闭新对话框遇到的问题和解决方法
- 修改DWZ的内置方法(openTab),实现搜索,弹出新的navTab
- viewcontroller上切换新方式
- iOS开发之Present ViewController Modally --弹出模态ViewController
- iOS开发之Present ViewController Modally --弹出模态ViewController
- adb remount 失败:remount failed: Operation not permitted
- PB数据窗口对象之画板、band和层次
- 利用.dSYM和.app文件准确定位Crash位置
- libGDX视频教程(九) -- 演员类(二)
- 半链接改写成关联
- 弹出新ViewController的方法
- Unable to execute dex: java.nio.BufferOverflowException.解决办法
- hibernate unique配置 和 异常的捕获
- Android paint字体的使用
- 对ms10-087(CVE-2010-3333)漏洞分析
- X001: selenium2.0关于python的常用函数
- memcached单点故障与负载均衡
- shell 小括号中括号大括号
- 在游戏中使用“CEGUI” — 第一章(底层)