在UIScrollView捏合手势上EXC_BAD_ACCESS代码= 1崩溃

时间:2013-05-22 21:00:17

标签: ios uiscrollview exc-bad-access

我的应用程序有一个带有一些项目的UIScrollView(例如UITextField),并且在大多数情况下,当视图加载此滚动视图时,我可以捏放大小,它可以正常工作。 / p>

但是,当我在控制台中放大和缩小时,有时会收到一些消息,如下所示:

CALayerGetSuperlayer called on instance of __NSArrayM
CALayerGetSuperlayer called on instance of NSShadow
CALayerGetSuperlayer called on instance of __NSCFString
CALayerGetSuperlayer called on instance of __NSCFType
CALayerGetSuperlayer called on instance of UIButtonContent

有时候我遇到了一个总是这样的崩溃:

* thread #1: tid = 0x2503, 0x3b8155b6 libobjc.A.dylib`objc_msgSend + 22, stop reason = EXC_BAD_ACCESS (code=1, address=0x4)
    frame #0: 0x3b8155b6 libobjc.A.dylib`objc_msgSend + 22
    frame #1: 0x3552e9d4 QuartzCore`CALayerGetSuperlayer + 92
    frame #2: 0x357c0e5e UIKit`-[UIView(Hierarchy) containsView:] + 34
    frame #3: 0x358eb3d4 UIKit`-[UITextSelectionView affectedByScrollerNotification:] + 140
    frame #4: 0x35a5b394 UIKit`-[UITextSelectionView scaleWillChange:] + 24
    frame #5: 0x338c7036 CoreFoundation`_CFXNotificationPost + 1426
    frame #6: 0x341dd598 Foundation`-[NSNotificationCenter postNotificationName:object:userInfo:] + 72
    frame #7: 0x341e105a Foundation`-[NSNotificationCenter postNotificationName:object:] + 30
    frame #8: 0x35910bea UIKit`-[UIScrollView _updatePinchGestureForState:] + 946
    frame #9: 0x3589bd88 UIKit`_UIGestureRecognizerSendActions + 128
    frame #10: 0x358633f4 UIKit`-[UIGestureRecognizer _updateGestureWithEvent:] + 392
    frame #11: 0x35a50a38 UIKit`___UIGestureRecognizerUpdate_block_invoke_0543 + 48
    frame #12: 0x3578782e UIKit`_UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks + 218
    frame #13: 0x35786292 UIKit`_UIGestureRecognizerUpdate + 1274
    frame #14: 0x357911e6 UIKit`-[UIWindow _sendGesturesForEvent:] + 766
    frame #15: 0x35790db2 UIKit`-[UIWindow sendEvent:] + 90
    frame #16: 0x3577e800 UIKit`-[UIApplication sendEvent:] + 380
    frame #17: 0x3577e11a UIKit`_UIApplicationHandleEvent + 6154
    frame #18: 0x374725a2 GraphicsServices`_PurpleEventCallback + 590
    frame #19: 0x374721d2 GraphicsServices`PurpleEventCallback + 34
    frame #20: 0x3394b172 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 34
    frame #21: 0x3394b116 CoreFoundation`__CFRunLoopDoSource1 + 138
    frame #22: 0x33949f98 CoreFoundation`__CFRunLoopRun + 1384
    frame #23: 0x338bcebc CoreFoundation`CFRunLoopRunSpecific + 356
    frame #24: 0x338bcd48 CoreFoundation`CFRunLoopRunInMode + 104
    frame #25: 0x374712ea GraphicsServices`GSEventRunModal + 74
    frame #26: 0x357d2300 UIKit`UIApplicationMain + 1120
    frame #27: 0x000134a4 MyApp`main(argc=3, argv=0x2fdefc68) + 48 at main.m:14
    frame #28: 0x00013470 MyApp`start + 40

我的应用程序使用ARC,我试图在僵尸打开的情况下运行,在这种情况下,应用程序崩溃,而且仪器没有显示任何问题。

关于可能会发生什么或如何处理此问题的任何想法?

编辑:根据史蒂夫的建议,我回去并重新检查僵尸打开,事实证明,我必须在第一次做错事。现在,当我在使用Instruments寻找僵尸的模拟器上运行时,当我尝试关闭包含包含控件的UIScrollView的模式对话框时,我会看到一个僵尸出现。这是僵尸出现时仪器的屏幕截图:

Zombieland

这里令人抓狂的是,在我遇到崩溃或僵尸出现之前,我必须多次打开和关闭模态。并且我没有看到任何我自己的代码出现在僵尸对象的对象摘要历史中。

1 个答案:

答案 0 :(得分:1)

事实证明,我的滚动视图中包含的UIView是我正在添加自己的项目,它覆盖了removeFromSuperview方法。当我进入该方法并添加了行

[self.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];

[super removeFromSuperview]调用之前,它现在似乎没有崩溃。