分享功能使用的UIPopoverController在iOS9 過時,替換爲popoverPresentationController

複製代碼

記錄一下 以備之後用到的時候拿出來看看。
之前使用的:
複製代碼
1 if (UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiom.Phone) {
2  presentViewController(vc, animated: true, completion: nil)
3 } else if (popover == nil || !popover!.popoverVisible) {
4                 popover = UIPopoverController(contentViewController: vc)
5              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 }
複製代碼
相關文章
相關標籤/搜索