iphone 与 ipad -- UIPopoverPresentationViewController
iOS8.0之后, 苹果推出了UIPopoverPresentationViewController, 在弹出控制器时, 统一采用 presentViewController,
但是要实现iPhone和iPad能够统一使用一段代码, 需要进行一些设置:
@implementation ViewController
// UIPopoverController只能用在iPad
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically fro
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
HMSecondViewController *vc = [[HMSecondViewController alloc] init];
// modal出来是个popover
vc.modalPresentationStyle = UIModalPresentationPopover;
// 取出vc所在的UIPopoverPresentationController
vc.popoverPresentationController.sourceView = self.slider;
vc.popoverPresentationController.sourceRect = self.slider.bounds;
[self presentViewController:vc animated:YES completion:nil];
}
@end
例如: UIAlertController
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"警告" message:@"你有严重的精神病,赶紧去治疗" preferredStyle:UIAlertControllerStyleActionSheet];
// 默认是POPover
alert.modalPresentationStyle = UIModalPresentationPopover;
// 设置popover指向的item
// alert.popoverPresentationController.barButtonItem = self.navigationItem.leftBarButtonItem;
alert.popoverPresentationController.sourceView = _clickBtn;
alert.popoverPresentationController.sourceRect = _clickBtn.bounds;
// 添加按钮
[alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
NSLog(@"点击了确定按钮");
}]];
[alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
NSLog(@"点击了取消按钮");
}]];
[self presentViewController:alert animated:YES completion:nil];
}
iphone 与 ipad -- UIPopoverPresentationViewController的更多相关文章
- 在Mac电脑上为iPhone或iPad录屏的方法
在以前的Mac和iOS版本下,录制iPhone或者iPad屏幕操作是一件稍微复杂的事情.但是随着Yosemite的出现,在Mac电脑上为iPhone或iPad录屏的方法就变得简单了.下面就介绍一下具体 ...
- iPhone与iPad在开发上的区别
*:first-child { margin-top: 0 !important; } body > *:last-child { margin-bottom: 0 !important; } ...
- iOS 为iPhone和iPad创建不同的storyboard
复制Main.storyboard,重命名为Main_iPad.storyboard 在info.plist文件中添加 Main storyboard file base name (iPad) -- ...
- css去掉iPhone、iPad默认按钮样式
原文链接:http://blog.sina.com.cn/s/blog_7d796c0d0102uyd2.html 只要在样式里面加一句去掉css去掉iPhone.iPad的默认按钮样式就可以了!~ ...
- CRM2013版本 IOS APP 说明(IPhone、IPad)
CRM2013版本 IOS APP 说明(IPhone.IPad) IPhone版本 首页 CRM APP在登录时输入账号信息,可以进行首面.其首页显示内容可以在CRM后台设置. 系统默认显示:Pho ...
- Iphone和iPad适配, 横竖屏
竖屏情况下: [UIScreen mainScreen].bounds.size.width = 320 [UIScreen mainScreen].bounds.size.width = 568 横 ...
- 【转】越狱的 iPhone、iPad 通过网站实现一键安装 ipa 格式的 APP 应用
1.已经越狱的 iPhone.iPad 设备,当通过其自带的 safari 浏览器访问 ipa 应用下载网站时,利用 itms-services 协议,可以一键安装 ipa 文件的 iOS 应用,例如 ...
- Professional iOS Network Programming Connecting the Enterprise to the iPhone and iPad
Book Description Learn to develop iPhone and iPad applications for networked enterprise environments ...
- daily news新闻阅读客户端应用源码(兼容iPhone和iPad)
daily news新闻阅读客户端应用源码(兼容iPhone和iPad),也是一款兼容性较好的应用,可以支iphone和ipad的阅读阅读器源码,设计风格和排列效果很不错,现在做新闻资讯客户端的朋友可 ...
随机推荐
- .NET技术-.NET各大网站-编程技术网址
Source Code: http://www.codeproject.com/ The Code Projecthttp://www.tomore.com/ 中 国盟动力http://www.cod ...
- 从零开始,打造自己的首个 iOS 框架
如果你曾试图创建自己的iOS框架,你知道这不是一个头脑发热作出的决定 — 管理依赖以及写测试用例一点也不简单.本教程将会带你从头到尾创建你的第一个iOS框架,让你可以创建自己的框架. 我们将在框架暴露 ...
- php笔记04:get/post请求有两种主要方式
get/post的区别有哪些? 1. 安全性get请求的数据会显示在地址栏上,post请求的数据,放在http协议的消息体中 2. 从可以提交的数据大小来看: http协议本身并没有限制数据大 ...
- 初识jsp
复习: 1.servlet生命周期: (1)默认是以第一次请求的时候创建并初始化Servlet,而且只做一次.(构造函数 init()) web.xml(配置后,是可以达到在服务启动后,立刻进行ser ...
- 深入理解计算机系统第二版习题解答CSAPP 2.8
给出位微量的布尔去处的求值结果. 运算 结果 a 0110 1001 b 0101 0101 ~a 1001 0110 ~b 1010 1010 a&b 0100 0001 a ...
- Winedt10 添加自定义宏
Winedt10 添加自定义功能,并在toolbar上添加快捷命令 功能描述: 用宏实现latex+bib参考文献的一键编译. Remark: The toolbar is the most visi ...
- 九度 1371 最小的K个数
题目描述:输入n个整数,找出其中最小的K个数.例如输入4,5,1,6,2,7,3,8这8个数字,则最小的4个数字是1,2,3,4,. 输入: 每个测试案例包括2行:第一行为2个整数n,k(1<= ...
- Optimal Logging
by Anthony Vallone How long does it take to find the root cause of a failure in your system? Five mi ...
- asp.net Ajax Post 请求一般处理程序
其实很早就开通博客园了,一直想写些有价值的东西,供自己以后查阅的同时,也可以帮助别人遇到此类问题时能有一个好的解决方法.但是由于各种原因, 就没有实施我的想法.今天突然很想写下一篇文章,不知道我的第一 ...
- SSIS结合BCP及SQL Server作业实现定时将数据导出打包实现数据同步
首先这个流程要实现的功能大致是: 有两台服务器,一台是对外网开发的,一台是内网的.那么很明显数据交互都是外网服务器在做,而这个流程要做的就是要将外网上面的数据定时同步到内网中. 我们依对其中某张表的操 ...