首页 > 移动平台 > 详细

iOS8新特性(2)——UIPopoverController

时间:2015-08-30 11:12:48      阅读:273      评论:0      收藏:0      [点我收藏+]

一、以往使用 UIPopoverController

  都是只在iPad上使用

 1 /**
 2  *  UIPopoverController 只能用于iPad,上,iPhone上使用会崩溃
 3  */
 4 -(void)old
 5 {
 6     VC2 *vc = [[VC2 alloc]init];
 7     
 8     UIPopoverController *popover = [[UIPopoverController alloc]initWithContentViewController:vc];
 9     [popover presentPopoverFromRect:self.btn.bounds inView:self.btn permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
10 }

 

二、统一的方式:

 1 -(void)new
 2 {
 3     VC2 *vc = [[VC2 alloc]init];
 4     
 5     //下面三行代码在iPhone中是会被忽略的
 6     //但是在iPad中是将我们的present当作是present一个popover
 7     //所以这是一种比较好的适配iPhone和iPad的共存方法
 8     vc.modalPresentationStyle = UIModalPresentationPopover;
 9     vc.popoverPresentationController.sourceRect = self.btn.bounds;
10     vc.popoverPresentationController.sourceView = self.btn;
11     
12     [self presentViewController:vc animated:YES completion:nil];
13 }

 

iOS8新特性(2)——UIPopoverController

原文:http://www.cnblogs.com/daomul/p/4770469.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!