UIWebViewTerminating app due to UIPopoverPresentationController

≡放荡痞女 提交于 2019-12-13 05:19:57

问题


In iOS 8 UIWebView I loaded a html page which has selection options via popover. Webview opens the native popover to show the options but the app is crashing when tapping the buttons. In iOS 7 its working fine. Following is the error message in iOS 8.

Terminating app due to uncaught exception 'NSGenericException',
reason: 'UIPopoverPresentationController
() should have a non-nil
sourceView or barButtonItem set before the presentation occurs.'


回答1:


After iOS8 you need to specify sourceView.

#define IS_IOS_8_AND_GREATER ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8)

if (IS_IOS_8_AND_GREATER) {
        activityController.popoverPresentationController.sourceView = self.view;
        activityController.popoverPresentationController.sourceRect = self.shareButton.frame;
}

and after that present it

[self presentViewController:activityController
                       animated:YES
                     completion:nil];


来源:https://stackoverflow.com/questions/26912903/uiwebviewterminating-app-due-to-uipopoverpresentationcontroller

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!