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

查看:17
本文介绍了当用户点击下拉列表 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 的 uiwebview 中解决这个问题?

Is there anyway to work around this in uiwebview in ios8?

使用 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天全站免登陆