【问题标题】:iOS 11 UIWebView drop down menus completely broken on iPad - UIPopoverControlleriOS 11 UIWebView 下拉菜单在 iPad 上完全损坏 - UIPopoverController
【发布时间】:2017-09-23 09:18:14
【问题描述】:

当使用 HTML 选择元素时,UIWebView 在 iPad 上呈现一个原生的 UIPopoverController 作为下拉列表(iPhone 使用 UIPickerView 可以正常工作)。

在 iOS11 上,这似乎完全被破坏了:

  • 在不选择选项的情况下单击外部下拉菜单以关闭会导致弹出框被关闭并立即重新呈现,有时为空
  • 当页面上有多个下拉菜单时,新列表的下拉菜单包含上一个列表中的元素
  • 选择第二次下拉时,首先重新打开
  • 偶尔会在左上角出现下拉菜单(估计是丢失了它的源视图)
  • 上述步骤偶尔会导致以下崩溃:

2017-09-23 09:43:13.190728+0100 Web[1779:86622] * 终止应用 由于未捕获的异常“NSInternalInconsistencyException”,原因: '未设置 UITableView 数据源' * 第一次抛出调用堆栈:( 0 CoreFoundation 0x000000010d4a01cb exceptionPreprocess + 171 1 libobjc.A.dylib
0x000000010c8bbf41 objc_exception_throw + 48 2 核心基础
0x000000010d4a5362 +[NSException raise:format:arguments:] + 98 3
基础 0x000000010c360089 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193 4
UIKit 0x000000010da742f5 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 1756 5 UIKit 0x000000010da7451a -[UITableView _createPreparedCellForRowAtIndexPath:willDisplay:] + 81 6 UIKit 0x000000010da82137 -[UITableView _heightForRowAtIndexPath:] + 208 7
UIKit 0x000000010dd2b939 -[UISectionRowData heightForRow:inSection:canGuess:] + 259 8 UIKit 0x000000010dd31c1a -[UITableViewRowData heightForRow:inSection:canGuess:adjustForReorderedRow:] + 277 9
UIKit 0x000000010dd36230 -[UITableViewRowData ensureHeightsFaultedInForScrollToIndexPath:withScrollPosition:boundsHeight:] + 964 10 UIKit 0x000000010da51110 -[UITableView _contentOffsetForScrollingToRowAtIndexPath:atScrollPosition:usingPresentationValues:] + 2783 11 UIKit 0x000000010da51b8f -[UITableView _scrollToRowAtIndexPath:atScrollPosition:animated:usingPresentationValues:] + 146 12 UIKit 0x000000010da51a11 -[UITableView scrollToRowAtIndexPath:atScrollPosition:animated:] + 123 13 UIKit 0x000000010de72d11 -[UIWebSelectTableViewController viewWillAppear:] + 247 14 UIKit 0x000000010dabe9b0 -[UIViewController _setViewAppearState:isAnimating:] + 444 15 UIKit 0x000000010dabf245 -[UIViewController __viewWillAppear:] + 147 16 UIKit 0x000000010da8b881 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 1088 17 UIKit
0x000000010d926c61 _runAfterCACommitDeferredBlocks + 318 18 UIKit
0x000000010d91530d _cleanUpAfterCAFlushAndRunDeferredBlocks + 280 19 UIKit 0x000000010d945600 _afterCACommitHandler + 137 20 核心基础 0x000000010d442db7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION
+ 23 21 核心基础 0x000000010d442d0e __CFRunLoopDoObservers + 430 22 CoreFoundation 0x000000010d427324 __CFRunLoopRun + 1572 23 CoreFoundation
0x000000010d426a89 CFRunLoopRunSpecific + 409 24 图形服务
0x00000001124c89c6 GSEventRunModal + 62 25 UIKit
0x000000010d91ad30 UIApplicationMain + 159 26 Web
0x000000010bfb014f 主要 + 111 27 libdyld.dylib
0x0000000110df1d81 开始 + 1 28 ???
0x0000000000000001 0x0 + 1`

我用一行代码创建了一个示例应用程序来演示该问题:

https://github.com/AshRobinson/BrokenUIWebView

http://gph.is/2xmHFWs

有没有人可以解决此类问题?在这个阶段,迁移到 WKWebview 不是我们的选择。

有什么办法可以强制 iPad 暂时按照 iPhone 使用UIPickerView 进行下拉菜单?

我调查了其他堆栈溢出帖子中的建议,但没有运气,例如:

ios 11 Beta 5 select drop-down list issue

【问题讨论】:

  • 遇到同样的问题。还没有解决方案。

标签: ipad uiwebview dropdown uipopovercontroller ios11


【解决方案1】:

我们遇到了同样的错误。 Apple's documentation 表示任何 iOS 8+ 应用程序都应该使用 WKWebView。一旦我们切换到 WKWebView,我们就不会再看到这个问题了。

【讨论】:

  • 即使升级了 WKWebView,我仍然看到同样的问题
  • @dmorrow 这是我非常简单的gist
【解决方案2】:

我遇到了这个问题,直接将 WKWebView 添加到 UIWindow 中。我的问题是视图没有链接到它的 UIViewcontroller,所以下面几行就可以了:

containerVC = [[UIViewController alloc] init];
[containerVC.view addSubview:myWkWebview];
[window addSubview:containerVC.view];

而不是将myWkWebview直接添加到窗口中。有了这个,模态视图又被添加了:-)

【讨论】:

    猜你喜欢
    • 2017-02-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-24
    • 2017-07-22
    • 2012-12-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多