iPhone SDK/iOS 在 webview/scrollview 中崩溃?

发布于 2024-10-26 15:02:52 字数 2142 浏览 2 评论 0原文

我的应用程序发生了非常奇怪的崩溃。它是随机发生的。基本上,我有一个包含多个 UIWebView 的大型滚动视图,我从 HTML 字符串加载这些视图。一段时间后,出现以下崩溃:

*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSMutableArray objectAtIndex:]: index 7 beyond bounds [0 .. 6]'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x0110dbe9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x00f025c2 objc_exception_throw + 47
    2   CoreFoundation                      0x011036e5 -[__NSArrayM objectAtIndex:] + 261
    3   CoreFoundation                      0x010866e5 -[NSMutableArray removeObject:range:identical:] + 437
    4   CoreFoundation                      0x01086520 -[NSMutableArray removeObject:] + 96
    5   UIKit                               0x0035e7c0 -[UIView(UIViewGestures) removeGestureRecognizer:] + 112
    6   UIKit                               0x005f85c1 -[UIWebSelectionAssistant setGestureRecognizers] + 58
    7   UIKit                               0x004b0d09 -[UIWebDocumentView loadHTMLString:baseURL:] + 286
    8   CoreFoundation                      0x0107e67d __invoking___ + 29
    9   CoreFoundation                      0x0107e551 -[NSInvocation invoke] + 145
    10  WebCore                             0x0217f3c3 _ZL15HandleAPISourcePv + 147
    11  CoreFoundation                      0x010ef01f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
    12  CoreFoundation                      0x0104d28b __CFRunLoopDoSources0 + 571
    13  CoreFoundation                      0x0104c786 __CFRunLoopRun + 470
    14  CoreFoundation                      0x0104c240 CFRunLoopRunSpecific + 208
    15  CoreFoundation                      0x0104c161 CFRunLoopRunInMode + 97
    16  WebCore                             0x02240423 _ZL12RunWebThreadPv + 499
    17  libSystem.B.dylib                   0x901ea85d _pthread_start + 345
    18  libSystem.B.dylib                   0x901ea6e2 thread_start + 34
)
terminate called after throwing an instance of 'NSException'

我真的无法解决这个问题,因为崩溃是随机的,并且似乎是在 CoreFoundation 中,我无法直接控制它。有什么建议吗?

非常感谢您的帮助!

I'm having really strange crash in my application. It occurs randomly. Basically, I'm having large scroll view containing multiple UIWebViews, which I'm loading from HTML string. After some time, following crash appears:

*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSMutableArray objectAtIndex:]: index 7 beyond bounds [0 .. 6]'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x0110dbe9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x00f025c2 objc_exception_throw + 47
    2   CoreFoundation                      0x011036e5 -[__NSArrayM objectAtIndex:] + 261
    3   CoreFoundation                      0x010866e5 -[NSMutableArray removeObject:range:identical:] + 437
    4   CoreFoundation                      0x01086520 -[NSMutableArray removeObject:] + 96
    5   UIKit                               0x0035e7c0 -[UIView(UIViewGestures) removeGestureRecognizer:] + 112
    6   UIKit                               0x005f85c1 -[UIWebSelectionAssistant setGestureRecognizers] + 58
    7   UIKit                               0x004b0d09 -[UIWebDocumentView loadHTMLString:baseURL:] + 286
    8   CoreFoundation                      0x0107e67d __invoking___ + 29
    9   CoreFoundation                      0x0107e551 -[NSInvocation invoke] + 145
    10  WebCore                             0x0217f3c3 _ZL15HandleAPISourcePv + 147
    11  CoreFoundation                      0x010ef01f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
    12  CoreFoundation                      0x0104d28b __CFRunLoopDoSources0 + 571
    13  CoreFoundation                      0x0104c786 __CFRunLoopRun + 470
    14  CoreFoundation                      0x0104c240 CFRunLoopRunSpecific + 208
    15  CoreFoundation                      0x0104c161 CFRunLoopRunInMode + 97
    16  WebCore                             0x02240423 _ZL12RunWebThreadPv + 499
    17  libSystem.B.dylib                   0x901ea85d _pthread_start + 345
    18  libSystem.B.dylib                   0x901ea6e2 thread_start + 34
)
terminate called after throwing an instance of 'NSException'

I really can not resolve this, because crashes are random and seem to be in CoreFoundation, which I do not controll directly. Any suggestion?

Thank you very much for any help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

待天淡蓝洁白时 2024-11-02 15:02:52

这并不是您问题的真正答案,但是:请注意,Apple 建议不要将 UIWebViews 放入 UIScrollViews 中。根据我的经验,这当然是可能的,但请注意可能会发生奇怪的事情。

相关问题:
UIScrollView 内有两个可调整大小的 UIWebView

Not really an answer to your issue, but: be aware that Apple recommend against putting UIWebViews inside UIScrollViews. It's certainly possible to do, in my experience, but just be warned that wacky things might happen.

Related question:
Two resizable UIWebViews inside UIScrollView

花间憩 2024-11-02 15:02:52

问题出在你的手势识别器上。 UIView 正在尝试删除可能不存在的识别器。它访问 6 元素数组的索引 7 导致崩溃。

我会检查您可能做过的手势的任何自定义。

The problem is in your gesture recognizers. The UIView is attempting to remove a recognizer that is presumably not there. It accesses index 7 of the 6 element array causing the crash.

I would check any customizations of the gestures you might have done.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文