您的位置:首页 > 产品设计 > UI/UE

iOS8下,UIImagePickerController的popoverPresentationController为空,要怎么获取?

2015-09-19 16:31 459 查看
想popover一个UIImagePickerController,结果发现UIImagePickerController的popoverPresentationController为空,怎么办?

在iOS8中,需要设置UIImagePickerController的modalPresentationStyle,如下:

imagePickerController.modalPresentationStyle = UIModalPresentationPopover;


然后,就可以使用popoverPresentationController了。如下:

UIPopoverPresentationController *popPC = imagePickerController.popoverPresentationController;
popPC.sourceView = imageView;
popPC.sourceRect = imageView.bounds;
[self presentViewController:imagePickerController animated:YES completion:nil];


注意:代码中sourceRect一定要使用bounds,而不能使用frame,不这么用的话,小心弹出的控制器的位置有问题。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: