0
votes

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
This link helped in fixing the issue. [link] (stackoverflow.com/questions/25908729/…)Raj kumar S.L

1 Answers

0
votes

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];