gpt4 book ai didi

ios - UIKit中与WebView相关的崩溃

转载 作者:行者123 更新时间:2023-12-01 16:09:31 25 4
gpt4 key购买 nike

我在UIKit中发生了一次随机崩溃,已经发生了两次。

它崩溃与EXC_BAD_ACCESS KERN_INVALID_ADDRESS at 0x0000000d

Thread : Crashed: com.apple.main-thread
0 libobjc.A.dylib 0x30e08f46 objc_msgSend + 5
1 UIKit 0x26d1790d -[_UIWebViewScrollViewDelegateForwarder forwardInvocation:] + 140
2 CoreFoundation 0x23654def ___forwarding___ + 354
3 CoreFoundation 0x23586df8 _CF_forwarding_prep_0 + 24
4 UIKit 0x26b5a6fd -[UIScrollView _getDelegateZoomView] + 84
5 UIKit 0x26b5a635 -[UIScrollView _zoomScaleFromPresentationLayer:] + 24
6 UIKit 0x26b5a5ed -[UIWebDocumentView _zoomedDocumentScale] + 64
7 UIKit 0x26b5a13d -[UIWebDocumentView _layoutRectForFixedPositionObjects] + 104
8 UIKit 0x26b59f97 -[UIWebDocumentView _updateFixedPositionedObjectsLayoutRectUsingWebThread:synchronize:] + 38
9 UIKit 0x26b5c3e5 -[UIWebDocumentView _updateFixedPositioningObjectsLayoutAfterScroll] + 28
10 UIKit 0x26b5c3c1 -[UIWebBrowserView _updateFixedPositioningObjectsLayoutAfterScroll] + 56
11 CoreFoundation 0x2360a281 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
12 CoreFoundation 0x2356652d _CFXNotificationPost + 1784
13 Foundation 0x24296189 -[NSNotificationCenter postNotificationName:object:userInfo:] + 72
14 UIKit 0x27171dd7 -[UIInputWindowController postEndNotifications:withInfo:] + 554
15 UIKit 0x271732ed __77-[UIInputWindowController moveFromPlacement:toPlacement:starting:completion:]_block_invoke595 + 368
16 UIKit 0x26b44b05 -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 308
17 UIKit 0x26b4471d -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 184
18 UIKit 0x26b4462f -[UIViewAnimationState animationDidStop:finished:] + 66
19 QuartzCore 0x2653d2d9 CA::Layer::run_animation_callbacks(void*) + 236
20 libdispatch.dylib 0x3135c7a7 _dispatch_client_callout + 22
21 libdispatch.dylib 0x3135ffa3 _dispatch_main_queue_callback_4CF + 718
22 CoreFoundation 0x236179d1 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 8
23 CoreFoundation 0x236160d1 __CFRunLoopRun + 1512
24 CoreFoundation 0x23564211 CFRunLoopRunSpecific + 476
25 CoreFoundation 0x23564023 CFRunLoopRunInMode + 106
26 GraphicsServices 0x2a95d0a9 GSEventRunModal + 136
27 UIKit 0x26b701d1 UIApplicationMain + 1440
28 MY_PROJECT 0x000842cf main (main.m:16)

看起来它与UIWebView有关,但是我不知道发生了什么-感谢您提供任何帮助
坠机事件在中国似乎是众所周知的...

最佳答案

正如@ NilsHolgerson提到的那样,我在通知方面遇到了一些问题。
最可能的原因是未正确删除的通知,并且确实保留了一个以其他方式分离的ViewController:

   [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillEnterForegroundNotification object:nil queue:nil usingBlock:^(NSNotification *note) {
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillEnterForegroundNotification object:nil];
...

解决方案如下所示:
__weak typeof(self) weakself = self;
__block NSObject *reference = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillEnterForegroundNotification object:nil queue:nil usingBlock:^(NSNotification *note) {
[[NSNotificationCenter defaultCenter] removeObserver:reference];
...

关于ios - UIKit中与WebView相关的崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27188342/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com