美文网首页
UIPopoverPresentationController

UIPopoverPresentationController

作者: 049b3aca6c0b | 来源:发表于2017-08-04 17:32 被阅读0次

MyViewController *viewController = [[MyViewController alloc] init];

viewController.modalPresentationStyle = UIModalPresentationPopover;

emptyViewController.preferredContentSize = CGSizeMake(300, 200);

UIPopoverPresentationController *pop = emptyViewController.popoverPresentationController;

pop.sourceRect = CGRectMake(10, 10, 20, 20);

pop.sourceView = self.view;

pop.delegate = self;

[self.navigationController presentViewController:emptyViewController animated:YES completion:nil];

如果想在 iPhone 上也显示为非全屏的弹出框,需要实现 UIPopoverPresentationControllerDelegate 协议的方法,返回 UIModalPresentationNone 即可:

- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller {

   return UIModalPresentationNone;

}

相关文章

网友评论

      本文标题:UIPopoverPresentationController

      本文链接:https://www.haomeiwen.com/subject/wmkblxtx.html