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的阅读阅读器源码,设计风格和排列效果很不错,现在做新闻资讯客户端的朋友可 ...
随机推荐
- 【转】Cocos2d-x 2.x CCSprite 灰白图的生成(利用shader设置)——2013-08-27 21
猴子原创,欢迎转载.转载请注明: 转载自Cocos2D开发网–Cocos2Dev.com,谢谢! 原文地址: http://www.cocos2dev.com/?p=325 游戏中人物死掉后要把人物头 ...
- Linux ps aux指令詳解--转
linux上进程有5种状态: 1. 运行(正在运行或在运行队列中等待) 2. 中断(休眠中, 受阻, 在等待某个条件的形成或接受到信号) 3. 不可中断(收到信号不唤醒和不可运行, 进程必须等待直到有 ...
- tinyxml_settattr
TiXmlString& TiXmlString::assign(const char* str, size_type len) { size_type cap = capacity(); * ...
- air2调用本地exe的文章
流传了两种配置app.xml的方法,分别是: <supportedProfiles>extendedDesktop</supportedProfiles> <suppo ...
- 组合模式(Composite Pattern)
组合模式定义:组合模式允许你将对象组合成树形结构来表现"整体/局部"层次结构,组合能让客户以一致的方式处理个别对象以及对象组合. 当涉及到如:菜单,子菜单之类的问题时,会自然而然的 ...
- js 如何判断数据是数据还是对象
如果用typeof测试,数组和对象都是显示的Object, 测试方式:var mycars=new Array();mycars[0]="Saab";mycars[1]=" ...
- SQLServe错误整理
1. sql拒绝访问?提示SQL Serve不存在或访问被拒绝 (SQL Server does not exist or access denied.) (A) 1:你如果是独立上网的请把21端口打 ...
- 【MINA】字节序知识
字节序,分为高位在前和低位在前,说白了就是先从低操作还是从高位操作 java和网络的字节序是一致的,都是高位在前,这意味着java端序列化和反序列化时不用关心字节序的问题, 那问题是,那讨论字节序有什 ...
- ElastciSearch常用APi
列出所有的索引: GET /_cat/indices?v 删除索引 DELETE /customer?pretty
- INI文件的读写
public class INIoperation { string inipath = Utils.GetMapPath("/Integration/Sync/set.ini") ...