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 ...
随机推荐
- 解决win8.1电脑无法安装手机驱动问题
相信安装过win8.1的朋友都会有个问题,那就是自己的安卓手机怎么都连不上电脑,比如360助手.豌豆荚.91助手,都安不上驱动.下面几个简单步骤即可轻松解决. 1.首先声明,官方的驱动是完全支持win ...
- BarTender连接不上数据库怎么办
由于各种原因,在使用BarTender连接到数据库时,有可能会出现无法连接的问题,下面下编就针对两种BarTender无法连接到数据库的问题,来教大家解决的方法. 第一种 BarTender无权打开文 ...
- 织梦Dedecms系统可疑文件include/filter.inc.php扫描出漏洞,该如何解决?
今天在做网站监察的时候,发现网站出了一个问题,在对网站做木马监测的时候,扫描出一个可疑文件:/include/filter.inc.php,建议删除,但仔细检查后,发现此文件是织梦(Dedecms)系 ...
- [原]unity3d刀光剑影(二)
本篇研究 暴走武侠 效果.直接贴代码 Shader "Cg shader with single texture" { Properties { _MainTex ("T ...
- [转]如何配置和使用Tomcat访问日志
配置位置在log下的server.xml,(tomcat容器) <Engine defaultHost="localhost" name="Catalina&quo ...
- phpVirtualBox – 用浏览器操作虚拟机
摘自:https://code.google.com phpVirtualBox 一个开源的,VirtualBox的用户界面,用PHP编写的AJAX实现.作为一个现代的Web界面,它允许你远程访问和控 ...
- 个人成长|荣获CNVD年度最有价值漏洞奖
本文共750+字,预计阅读2-3分钟. 前几天,很荣幸受主办方邀请,还拿了CNVD的一个“年度最有价值漏洞奖”,说一说,这几天的故事吧. 11月20号,意外收到一个会议邀请,当时还比较诧异,印象中我在 ...
- ActiveX 控件导入程序
ActiveX 控件导入程序将 ActiveX 控件的 COM 类型库中的类型定义转换为 Windows 窗体控件. http://msdn.microsoft.com/zh-cn/library/8 ...
- (转)作为一个新人,怎样学习嵌入式Linux?(韦东山)
被问过太多次,特写这篇文章来回答一下. 在学习嵌入式Linux之前,肯定要有C语言基础.汇编基础有没有无所谓(就那么几条汇编指令,用到了一看就会).C语言要学到什么程度呢?越熟当然越好,不熟的话也 ...
- Python对文件和文件路径的管理
1. 使用os.path进行路径和文件管理 1.1 拆分路径 os.path.split 返回一个二元组,包含文件路径和文件名 os.path.dirname ...