当用户点击下拉列表HTML选择标记时,ios8 iPad uiwebview在显示弹出窗口时崩溃 [英] ios8 iPad uiwebview crashes while displaying popover when user taps drop down list HTML select tag

查看:93
本文介绍了当用户点击下拉列表HTML选择标记时,ios8 iPad uiwebview在显示弹出窗口时崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在ios8和iPad上如果 uiwebview 显示包含下拉列表的HTML页面

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

例如页面 http://www.w3schools.com/tags/tryit.asp?filename= tryhtml_select

然后


  • 反复点击HTML下拉列表包含汽车列表的列表。第一项是沃尔沃。

  • 每隔1/2秒左右点击一下uipopover打开和关闭

  • 应用程序将崩溃:


由于未捕获的异常'NSGenericException'终止应用程序,
原因:'UIPopoverPresentationController
()应该有在演示文稿发生之前设置的非零
sourceView或barButtonItem。'

Terminating app due to uncaught exception 'NSGenericException', reason: 'UIPopoverPresentationController () should have a non-nil sourceView or barButtonItem set before the presentation occurs.'

无论如何都要在<在ios8中code> uiwebview ?

使用 wkwebview 不会发生,但我想在中修复它uiwebview

It doesn't happen using wkwebview, but I would like to fix it in uiwebview.

更新:这似乎有助于但不确定副作用。我在包含uiwebview的视图控制器中覆盖了以下内容。

Update: This seems to help but unsure of side effects. I have overridden the following in the view controller that contains the uiwebview.

-(void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion
{
    if (completion)
    {
        completion();
    }

    [super dismissViewControllerAnimated:NO completion:nil];
}


推荐答案

问题中提到的解决方案并没有帮助我,但它确实指出了我正确的方向。
经过一番调查后,我会说在呈现和移除弹出窗口之间存在某种竞争条件。作为一种解决方法,您可以将演示文稿推迟到UIWebView的委托中:

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

这篇关于当用户点击下拉列表HTML选择标记时,ios8 iPad uiwebview在显示弹出窗口时崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆