在 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
然后
由于未捕获的异常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 在显示弹出窗口时崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!