IOS UIPopoverPresentationController

从iOS 8开始,苹果提出新的 UIPopoverPresentationController代替UIPopoverController。代码如下:



//创建你需要显示的controller
UIViewController *cityAlertViewController = [[UIViewController alloc] init]; 
//这里自定义的view
DLpopupView *popupView = [[DLpopupView alloc] initWithFrame:CGRectMake(0.0, 0.0, 
[300, 91) andRestorationName:@“DCpopupView”]; 

cityAlertViewController.view = popupView; 
//设置modal类型
cityAlertViewController.modalPresentationStyle = UIModalPresentationPopover; cityAlertViewController.preferredContentSize = CGSizeMake(300, 91); 
//配置 UIPopoverPresentationController 
UIPopoverPresentationController *cityErrorPopover = cityAlertViewController.popoverPresentationController; 
//设置代理
cityErrorPopover.delegate = self;
//设置相关属性
  cityErrorPopover.sourceView = self.view;
cityErrorPopover.sourceRect = button.frame; cityErrorPopover.permittedArrowDirections = 
UIPopoverArrowDirectionUp; cityErrorPopover.backgroundColor = greenNormal;
// pop跳转
[self presentViewController:cityAlertViewController animated:YES completion:nil];

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 课余饭后,走在校园的路上,看着“深秋”的景色(相对于北方而说,北方现在已经是冬季景象了),感慨非常。 一片片叶子自...
    DIGITALMAN阅读 706评论 0 4
  • 以前的我,很讨厌别人在背后说我坏话,虽然现在也是很讨厌。 在十几岁的青春,我们总是很偏袒自己人。总觉...
    浅与净阅读 486评论 0 1