0

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.'

n0p
  • 3,399
  • 2
  • 29
  • 50
Raj kumar S.L
  • 101
  • 1
  • 5
  • This link helped in fixing the issue. [link] (http://stackoverflow.com/questions/25908729/ios8-ipad-uiwebview-crashes-while-displaying-popover-when-user-taps-drop-down-li) – Raj kumar S.L Nov 16 '14 at 13:49

1 Answers1

0

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];
l0gg3r
  • 8,864
  • 3
  • 26
  • 46
  • Thanks for the replay. In my case I don't have the button in my control to specify the SourceRect as the button is in the web view. The link specified in above post fixed my issue. – Raj kumar S.L Nov 16 '14 at 13:52