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

分享功能使用的UIPopoverController在iOS9 过期,替换为popoverPresentationController

2015-11-20 17:54 471 查看
记录一下 以备以后用到的时候拿出来看看。
以前使用的:


if (UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiom.Phone) {
presentViewController(vc, animated: true, completion: nil)
} else if (popover == nil || !popover!.popoverVisible) {
popover = UIPopoverController(contentViewController: vc)
popover!.delegate = self                         popover?.presentPopoverFromRect(inviteView.frame, inView: self.view, permittedArrowDirections: UIPopoverArrowDirection.Any, animated: true)


现在使用:
if #available(iOS 8.0, *) {
vc.modalPresentationStyle = UIModalPresentationStyle.Popover
vc.popoverPresentationController?.sourceView = inviteView
vc.popoverPresentationController?.sourceRect = inviteView.bounds
vc.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection.Any
presentViewController(vc, animated: true, completion: nil)
} else {
//DeviceUtils.isIOS7()
if (UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiom.Phone) {
presentViewController(vc, animated: true, completion: nil)
} else if (popover == nil || !popover!.popoverVisible) {
popover = UIPopoverController(contentViewController: vc)
popover!.delegate = self
popover?.presentPopoverFromRect(inviteView.frame, inView: self.view, permittedArrowDirections: UIPopoverArrowDirection.Any, animated: true)
}
// Fallback on earlier versions
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: