iOS8新特性(2)——UIPopoverController和UIPresentationController
一、以往使用 UIPopoverController
都是只在iPad上使用
/**
* UIPopoverController 只能用于iPad,上,iPhone上使用会崩溃
*/
-(void)old
{
VC2 *vc = [[VC2 alloc]init]; UIPopoverController *popover = [[UIPopoverController alloc]initWithContentViewController:vc];
[popover presentPopoverFromRect:self.btn.bounds inView:self.btn permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
二、统一的方式:
-(void)new
{
VC2 *vc = [[VC2 alloc]init]; //下面三行代码在iPhone中是会被忽略的
//但是在iPad中是将我们的present当作是present一个popover
//所以这是一种比较好的适配iPhone和iPad的共存方法
vc.modalPresentationStyle = UIModalPresentationPopover;
vc.popoverPresentationController.sourceRect = self.btn.bounds;
vc.popoverPresentationController.sourceView = self.btn; [self presentViewController:vc animated:YES completion:nil];
}
- (void)viewDidLoad {
[super viewDidLoad];
ViewController2 *vc2 = [[ViewController2 alloc]init];
//vc2.modalPresentationStyle = UIModalPresentationFormSheet;//弹出在中间
vc2.modalPresentationStyle = UIModalPresentationPopover; //popover的形式弹出
vc2.popoverPresentationController.barButtonItem = self.navigationItem.leftBarButtonItem;
[self presentViewController:vc2 animated:YES completion:nil];
}
三、机制
1、只要一调用[self presentViewController:vc2 animated:YES completion:nil];
2、首先会生成一个UIPresentationController
3、然后由UIPresentationController管理控制器的切换
4、无论设置UIModalPresentationFormSheet还是UIModalPresentationPopover模式,都是UIPresentationController来管理
四、一些重要的属性
UIPresentationController *p;
p.presentingViewController; //底部正在弹出的控制器(主)
p.presentedViewController; //已经弹出来的控制器(被)
p.presentedView; //已经被弹出来的控制器的view
vc2.presentationController; //控制“已经弹出来的控制器” 的控制器:就是 p或者p的自控制器 (只读,内部采用懒加载的方式,所以不要去改)
vc2.popoverPresentationController //如果设置style为popover出来的就同上,否则不设置style或者设置其他style就是nil
iOS8新特性(2)——UIPopoverController和UIPresentationController的更多相关文章
- iOS8 新特性
iOS8新特性主要体现在4方面 1.UIAlertController 对alert&actionSheet的封装 UIAlertController.h 提示框按钮的选择 typedef N ...
- iOS8新特性(1)——UIAlertController
一.iOS8介绍 iOS8 新特性,主要是UI上进行了统一 1.UIAlertController 2.UIPresentaionController:管理所有通过modal出来的控制器(看笔记) 3 ...
- ios8新特性widget开发-b
os8发布已经有一段时间了,伴随着ios8同时也出现了许多新的特性,ios系统将会越来越开放,这是好事.其中一个新特性就是在下拉通知栏里加入了个性的widget,开发者可以自己定义widget的样式内 ...
- iOS8新特性
1. App Extension Programming Guide 2.LocalAuthentication.framework - Touch ID Authentication 3.Local ...
- iOS iOS8新特性--UIPopoverPresentationController
1.回顾UIPopoverController的使用,下面这份代码只能在ipad下运行 // 初始化控制器,SecondViewController类继承自UIViewController Secon ...
- iOS8新特性(1)-UIPopoverPresentationController使用
从iOS 8开始,苹果提出新的 UIPopoverPresentationController代替UIPopoverController: 新的UIPopoverPresentationControl ...
- 利用iOS8新特性计算cell的实际高度
在计算cell的实际高度是 我们一般是通过计算frame 拿到最底部一个控件的最大Y值从而的到cell 的高度 算来算去 比较麻烦 其实,iOS8已经提供了直接通过Cell高度自适应的方法了,根 ...
- iOS8新特性之基于地理位置的消息通知UILocalNotification
苹果在WWDC2014上正式公布了全新的iOS8操作系统. 界面上iOS8与iOS7相比变化不大,只是在功能方面进行了完好. ...
- iOS8新特性之交互式通知
目前分为四个推送:用户推送,本地推送,远程推送,地理位置推送. if (IS_IOS8) { //1.创建消息上面要添加的动作(按钮的形式显示出来) UIMutableUserNotification ...
随机推荐
- Webkit内核探究【1】——Webkit简介
出处:http://www.cnblogs.com/jyli/archive/2010/01/31/1660355.html作者:李嘉昱 研究Webkit内核已经有一段时间了,在这期间我花了很多时间去 ...
- MVC使用 Elmah 日志记录组件
在后台管理中,有一些操作是需要增加操作日志的,尤其是对一些比较敏感的金额类的操作,比如商城类的修改商品金额.删除商品.赠送金额等人工的操作.日志中记录着相关操作人的操作信息,这样,出了问题也容易排查. ...
- mysql中如何查看某个日期所在的周一是几号?某个日期所在的一周开始时间是几号?
需求描述: 在编写SQL的时候,有这么个需求,就是要查出来某个日期所在的周一是几号,进行了测试,在此进行记录下. 测试过程: 议题:查看某个日期所在的周一是几号 分析:如果某个日期是周一,那么加上整数 ...
- 既使用maven又使用lib下的Jar包
maven 使用本地包 lib jar包 依赖一个lib目录 解决方法: # 把本地的lib加入maven编译时的依赖路径 From:http://blog.chinaunix.net/uid-231 ...
- dos命令收集
应用程序和进程相关 tasklist /svc 查看计算机当前正在运行程序 taskkill /f /im "eclipse.exe" 关闭指定的应用程序 taskk ...
- mongodb常用操作命令(待续)
1. 开启mongodb命令 >mongo 默认链接到test数据库 2. 显示所有数据库>show dbs 3.切换数据库>use 数据库名 4.查找数据库里某张表的所有成员> ...
- HTTP API接口测试利器PostMan介绍
一.什么是API接口测试? API接口有多种,个人将其划分为三类.第一种是函数级别的,测试需要对接口的各个参数进行测试,如:Int getResult(String key, String ID, I ...
- 04python while循环语句
使用while ture语法 luck_num = 33 flag = True while flag: guess_num = input('请输入您猜测的年龄:') if guess_num &l ...
- iOS开发--关闭ARC
对整个项目关闭ARC project -> Build settings -> Apple LLVM complier 3.0 - Language -> objective-C A ...
- CentOS7安装ipython
python版本:2.7.5 yum install -y python2-pip.noarchyum install -y python-develpip install ipython==5.4. ...