see*_*ble 42 objective-c uiwebview ios8
在ios8和iPad上,如果a uiwebview显示包含下拉列表的HTML页面
例如,这个页面http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_select
然后
由于未捕获的异常'NSGenericException'而终止应用程序,原因是:'UIPopoverPresentationController()应该在演示发生之前设置一个非零的sourceView或barButtonItem.
无论如何uiwebview在ios8中解决这个问题?
它不会发生使用wkwebview,但我想修复它uiwebview.
更新:这似乎有助于但不确定副作用.我在包含uiwebview的视图控制器中覆盖了以下内容.
-(void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion
{
if (completion)
{
completion();
}
[super dismissViewControllerAnimated:NO completion:nil];
}
Run Code Online (Sandbox Code Playgroud)
dog*_*god 42
问题中提到的解决方案对我没有帮助,但它确实指出了我正确的方向.经过一番调查后,我会说在呈现和移除弹出窗口之间存在某种竞争条件.作为一种解决方法,您可以将演示文稿推迟到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];
});
}
Run Code Online (Sandbox Code Playgroud)
以前的解决方案对我没有帮助.
Apple已经记录了一个错误(请参阅openradar).
问题似乎是Web视图尝试在弹出框中呈现视图控制器而不设置弹出窗口的sourceView.虽然这绝对是一个Apple问题,但我使用了以下解决方法来避免我的应用程序崩溃:
- (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];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11188 次 |
| 最近记录: |