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

前端 未结 5 1666
生来不讨喜
生来不讨喜 2020-11-30 21:00

On ios8 and iPad if a uiwebview is displaying a HTML page containing a drop down list

eg this page http://www.w3schools.com/tags/tryit.asp?filename=tryh

5条回答
  •  -上瘾入骨i
    2020-11-30 21:35

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

提交回复
热议问题