首页 > 解决方案 > 在 iOS 13 中单击 webview 的链接时它会崩溃

问题描述

当点击 webview 中的链接时,没有响应。当长按链接时,它会崩溃并显示以下消息:

Trapped uncaught exception 'NSInternalInconsistencyException', reason: '_UIClickPresentationInteraction cannot determine presenting view controller.'

0   CoreFoundation                      0x00007fff23b98bde __exceptionPreprocess + 350
1   libobjc.A.dylib                     0x00007fff503b5b20 objc_exception_throw + 48
2   CoreFoundation                      0x00007fff23b98958 +[NSException raise:format:arguments:] + 88
3   Foundation                          0x00007fff255eb6f5 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 191
4   UIKitCore                           0x00007fff470cf0fd -[_UIClickPresentationInteraction _canPerformPresentation] + 431
5   UIKitCore                           0x00007fff470d16eb -[_UIClickPresentationInteraction _handleTransitionToPreview] + 136
6   UIKitCore                           0x00007fff470d1046 __55-[_UIClickPresentationInteraction _prepareStateMachine]_block_invoke_3 + 35
7   UIKitCore                           0x00007fff471f0fb0 -[_UIStateMachine handleEvent:withContext:] + 412
8   UIKitCore                           0x00007fff470cff63 -[_UIClickPresentationInteraction clickInteractionDidClickUp:] + 55
9   UIKitCore                           0x00007fff46dd5aed -[_UIClickInteraction clickDriver:didPerformEvent:] + 316
10  UIKitCore                           0x00007fff46a3831f __58-[_UILongPressClickInteractionDriver _prepareStateMachine]_block_invoke_2 + 74
11  UIKitCore                           0x00007fff471f0fb0 -[_UIStateMachine handleEvent:withContext:] + 412
12  UIKitCore                           0x00007fff46a38e04 -[_UILongPressClickInteractionDriver _updateForActiveGestureRecognizer] + 673
13  UIKitCore                           0x00007fff46a38a59 -[_UILongPressClickInteractionDriver _handleGestureRecognizer:] + 382
14  UIKitCore                           0x00007fff46d1e777 -[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:] + 44
15  UIKitCore                           0x00007fff46d27909 _UIGestureRecognizerSendTargetActions + 109
16  UIKitCore                           0x00007fff46d24fc5 _UIGestureRecognizerSendActions + 298
17  UIKitCore                           0x00007fff46d242f2 -[UIGestureRecognizer _updateGestureForActiveEvents] + 757
18  UIKitCore                           0x00007fff46d16308 _UIGestureEnvironmentUpdate + 2700
19  CoreFoundation                      0x00007fff23afaeb7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
20  CoreFoundation                      0x00007fff23af594e __CFRunLoopDoObservers + 430
21  CoreFoundation                      0x00007fff23af5fca __CFRunLoopRun + 1514
22  CoreFoundation                      0x00007fff23af56b6 CFRunLoopRunSpecific + 438
23  GraphicsServices                    0x00007fff3815cbb0 GSEventRunModal + 65
24  UIKitCore                           0x00007fff47162a67 UIApplicationMain + 1621
25  IBUWireless                         0x000000010b372728 main + 296
26  libdyld.dylib                       0x00007fff5123bcf5 start + 1
27  ???                                 0x0000000000000001 0x0 + 1

iOS13 操作系统

标签: ios

解决方案


I have recently fixed this issue and solved by setting

    webviewcontroller.modalPresentationStyle = .fullScreen

    self.present(webviewcontroller, animated: animated, completion: nil)

推荐阅读