问题
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