ios8 iPad uiwebview crashes while displaying popover when user taps drop down list HTML select tag ios8 iPad uiwebview crashes while displaying popover when user taps drop down list HTML select tag objective-c objective-c

ios8 iPad uiwebview crashes while displaying popover when user taps drop down list HTML select tag


The solution mentioned in the question did not help me, however it did point me in the right direction.After some investigation I would say it's some sort of race condition between presenting and removing the popover. As a workaround you can postpone the presentation in the delegate of the UIWebView:

-(void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion{    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_USEC), dispatch_get_main_queue(),               ^{                   [super presentViewController:viewControllerToPresent animated:flag completion:completion];               });}


The previous solutions did not help me.

There is a bug already logged to Apple (see openradar) for this.

The issue seems to be that the web view tries to present a view controller in a popover without setting the sourceView of the popover. Although it's definitely an Apple issue I have used the following workaround to avoid my app to crash:

- (void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion{    // Override this method in the view controller that owns the web view - the web view will try to present on this view controller ;)    if (viewControllerToPresent.popoverPresentationController && !viewControllerToPresent.popoverPresentationController.sourceView) {        return;    }    [super presentViewController:viewControllerToPresent animated:flag completion:completion];}


I worked around it in the following way after noticing that sourceView is set in the cases where it crashes:

-(void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion {  UIPopoverPresentationController* pres = viewControllerToPresent.popoverPresentationController;  if(pres.sourceView) {    //log the fact you are ignoring the call  }  else {    [super presentViewController:viewControllerToPresent animated:flag completion:completion];  }}