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 ...
随机推荐
- zabbix监控系列(5)之通过trap模式监控网络设备
- Fedora 安装oracle11g 之最简洁方式
最新的Fedora 24已经释出. 赶紧尝试安装oracle11g一把.很简单,很方便. 此处以最最简洁方式来安装一把! 环境: windows xp + virtualbox ,安装 fedora ...
- 元素随屏幕滚动到顶部固定js效果
网站中常见这种效果,某个广告或详情页切换tab,当屏幕向下移动时,该元素会停留在浏览器最顶部,下面ecshop模板中心教您实现js代码: 案例图: 1.首先在页面上找到该元素 加上 id =&quo ...
- 源码分析五(HashSet的内部实现)
一:首先来看看Hashset的继承体系 public class HashSet<E> extends AbstractSet<E> implements Set<E&g ...
- js实现webSocket客户端
var ws = new WebSocket("ws://localhost:8080/msg"); //readyState属性返回实例对象的当前状态,共有四种. //CONNE ...
- SpringMVC由浅入深day02_7上传图片
7 上传图片 7.1 需求 在修改商品页面,添加上传商品图片功能. 7.2 springmvc中对多部件类型解析 在页面form中提交enctype="multipart/form-data ...
- Eclipse Maven 配置setting.xml 的镜像远程仓库
1.在.m2中新建settings.xml文件 1.window-->Preferences-->Maven-->User Settings 3.点击open file 编辑将远程仓 ...
- Log4net用法(.config文件)
1.引用log4net.dll 2.在AssemblyInfo.cs中添加初始化: [assembly: log4net.Config.XmlConfigurator(ConfigFile = &qu ...
- hwi-web安装
hwi是hive的简单简单web端 安装hwi之前需要下载apache-hive-2.1.1-src,将hwi/web的打成hive-hwi-2.1.1.war.安装配置apache-ant-1.10 ...
- asp.net 验证码
Before proceeding with the topic first we must understand "What is a Captcha code?" and &q ...