使用 HTML 选择元素时,UIWebView
会在 iPad 上将原生 UIPopoverController
作为下拉列表呈现(iPhone 使用 UIPickerView
工作正常)。
在 iOS11 上,这似乎完全被破坏了:
2017-09-23 09:43:13.190728+0100 Web[1779:86622] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource is not set' * First throw call stack: ( 0 CoreFoundation 0x000000010d4a01cb exceptionPreprocess + 171 1 libobjc.A.dylib
0x000000010c8bbf41 objc_exception_throw + 48 2 CoreFoundation
0x000000010d4a5362 +[NSException raise:format:arguments:] + 98 3
Foundation 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 CoreFoundation 0x000000010d442db7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 23 21 CoreFoundation 0x000000010d442d0e __CFRunLoopDoObservers + 430 22 CoreFoundation 0x000000010d427324 __CFRunLoopRun + 1572 23 CoreFoundation
0x000000010d426a89 CFRunLoopRunSpecific + 409 24 GraphicsServices
0x00000001124c89c6 GSEventRunModal + 62 25 UIKit
0x000000010d91ad30 UIApplicationMain + 159 26 Web
0x000000010bfb014f main + 111 27 libdyld.dylib
0x0000000110df1d81 start + 1 28 ???
0x0000000000000001 0x0 + 1`
我用一行代码创建了一个示例应用程序,它演示了这个问题:
https://github.com/AshRobinson/BrokenUIWebView
http://gph.is/2xmHFWs
有没有人有解决此类问题的方法?在这个阶段,迁移到
WKWebview
不是我们的选择。有什么方法可以强制 iPad 临时使用
UIPickerView
进行 iPhone 的下拉列表?我已经调查了其他堆栈溢出帖子中的建议,但没有运气,例如:
ios 11 Beta 5 select drop-down list issue
最佳答案
我们遇到了同样的错误。 Apple's documentation说任何 iOS 8+ 的应用程序都应该使用 WKWebView。一旦我们切换到 WKWebView,我们就不再看到这个问题。
关于ipad - iOS 11 UIWebView 下拉菜单在 iPad 上完全损坏 - UIPopoverController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46377990/