关于UIPopoverPresentationController
来源:互联网 发布:新网域名证书下载 编辑:程序博客网 时间:2024/05/17 22:04
这次写这个UIPopoverPresentationController,是因为这段时间在用UIPopoverController,可是发现他会警告说这个已经过时了,请使用UIPopoverPresentationController。写的特别简单,但是肯定已经够大家用了... ...
本来想把具体属性写出来的,发现还不如直接用代码打给大家看... ...
//这里是我直接用storyboard拖的一个button方法
- (IBAction)add:(id)sender {
//用UIViewController或者自定义(这里我使用的是自定义的) - - 这里一般用自定义的,好添加控件,好操作啊
NewViewController *vc = [NewViewControllernew];
//这里必须设成UIModalPresentationPopover的形式,要不然大小是不好控制,特别是对于iPhone来说
vc.modalPresentationStyle =UIModalPresentationPopover;
//设置源视图,这里建议直接设成button本身就行
vc.popoverPresentationController.sourceView = sender;
//这里是设置你希望展示的大小
vc.preferredContentSize =CGSizeMake(100,100);
/*这里是展示的位置,他是相对于你前面设置的sourceView...PS:苹果开发文档说这里是设置相对位置和大小的,其实只能设置位置,后面的两位数没什么luan用
注:这里的坐标是相对于button(也就是sourceview)的左顶点,你可以把button想像成他的父视图也行
*/
vc.popoverPresentationController.sourceRect =CGRectMake(20,0,0,0);//这里我的button是40×40的,(20,0)就是button的上面居中位置,就是下面图片那个白色突出的尖(呵呵呵... ...)
/*
UIPopoverArrowDirectionUp = 1UL << 0,向上
UIPopoverArrowDirectionDown = 1UL << 1,向下
UIPopoverArrowDirectionLeft = 1UL << 2,向左
UIPopoverArrowDirectionRight = 1UL << 3,向右
UIPopoverArrowDirectionAny = UIPopoverArrowDirectionUp | UIPopoverArrowDirectionDown | UIPopoverArrowDirectionLeft | UIPopoverArrowDirectionRight, 根据button相对view的位置自动选择
UIPopoverArrowDirectionUnknown = NSUIntegerMax还不知道
*/
//箭头指向
[vc.popoverPresentationControllersetPermittedArrowDirections:UIPopoverArrowDirectionUp];
//设置代理(一定要设)
vc.popoverPresentationController.delegate =self;
//展示出来
[selfpresentViewController:vcanimated:YEScompletion:nil];
}
下面的图片:红色就是sourceview(button),蓝色就是弹出来的控制器,里面那个橘色的我是测试用的一个button
- 关于UIPopoverPresentationController
- UIPopoverPresentationController -
- UIPopoverPresentationController
- UIPopoverPresentationController用法
- reason: 'UIPopoverPresentationController (<UIPopoverPresentationController: 0x7f223f40>)。。。
- UIPopoverPresentationController的使用
- UIPopoverPresentationController简单使用
- iOS8之UIPopoverPresentationController
- Iphone上使用UIPopoverPresentationController
- UIPopoverPresentationController的使用
- UIPopoverPresentationController 小窗口控制器
- iOS UIPopoverPresentationController的使用
- ios-UIPopoverController和UIPopoverPresentationController
- iphone利用UIPopoverPresentationController实现popover
- iOS中UIPopoverPresentationController的用法
- iOS -- UIPopoverPresentationController 实现弹框
- iOS8新特性UIAlertViewController,UISearchController,UIPopoverPresentationController,WKWebView
- UIPopoverPresentationController 弹出 UIViewController 包裹的 UICollectionView
- 关于上下文切换的思考
- android 自己的思路写的订单管理界面
- 蓝牙标准介绍
- 判断App是不是第一次启动
- 假如UI提供的是矢量图
- 关于UIPopoverPresentationController
- linux系统中设置静态ip地址
- adb获取android手机系统版本,已对应的api版本和硬件相关信息
- 在IPython下如何将常用模块的目录添加到模块的搜索路径下
- Git远程操作详解
- 替换空格
- Adnroid中ViewPager的使用(三)PagerTabStrip的使用
- Android初学习 - onNewIntent()触发机制及注意事项
- $.extend()