UICollectionView在unhighlightAllItems上崩溃

Sco*_*sak 8 objective-c ios uicollectionview ios7

我收到了几个与iOS 7中的UICollectionView相关的崩溃报告.我无法一致地重新创建这个崩溃.

Exception Type:  SIGSEGV
Exception Codes: SEGV_ACCERR at 0x91c4392b
Crashed Thread:  0

Application Specific Information:
*** Terminating app due to uncaught exception '', reason: ''

Thread 0 Crashed:
0   libobjc.A.dylib                     0x39dd2b26 objc_msgSend + 6
1   UIKit                               0x31fd5eef -[UICollectionView cellForItemAtIndexPath:] + 111
2   UIKit                               0x32060bfd -[UICollectionView _unhighlightItemAtIndexPath:animated:notifyDelegate:] + 149
3   UIKit                               0x32383947 -[UICollectionView _unhighlightAllItems] + 151
4   UIKit                               0x3205f9fb -[UICollectionView touchesBegan:withEvent:] + 367
5   UIKit                               0x31fcb101 forwardTouchMethod + 233
6   UIKit                               0x31fcb101 forwardTouchMethod + 233
7   UIKit                               0x31e3be4b _UIGestureRecognizerUpdate + 5523
8   UIKit                               0x31e73c41 -[UIWindow _sendGesturesForEvent:] + 773
9   UIKit                               0x31e735e7 -[UIWindow sendEvent:] + 667
10  UIKit                               0x31e48a25 -[UIApplication sendEvent:] + 197
11  UIKit                               0x31e47221 _UIApplicationHandleEventQueue + 7097
12  CoreFoundation                      0x2f69e18b __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
13  CoreFoundation                      0x2f69d6e1 __CFRunLoopDoSources0 + 341
14  CoreFoundation                      0x2f69be4f __CFRunLoopRun + 623
15  CoreFoundation                      0x2f606ce7 CFRunLoopRunSpecific + 523
16  CoreFoundation                      0x2f606acb CFRunLoopRunInMode + 107
17  GraphicsServices                    0x342f4283 GSEventRunModal + 139
18  UIKit                               0x31ea8a41 UIApplicationMain + 1137
19  JackThreadsIpad                     0x000922b7 main (main.m:16)
Run Code Online (Sandbox Code Playgroud)

应用程序中的UICollectionViewCells共享一个管理突出显示的公共超类.当单元格突出显示时,alpha会发生变化.

- (void)setHighlighted:(BOOL)highlighted {
    [super setHighlighted:highlighted];

    if (highlighted) {
        self.alpha = 0.8;
    } else {
        self.alpha = 1.0;
    }
}
Run Code Online (Sandbox Code Playgroud)

可以调用[super setHighlighted:highlight]导致这样的崩溃吗?该应用程序是使用XCode 4编译和提交的,并且仅在iOS 7上发生.还有任何其他建议可以确定这种情况发生的位置.谢谢你的帮助.

编辑:我能够在调试器中捕获它,但它仍然不能始终如一地重现.崩溃是:

[NSIndexPath section] message sent to deallocated instance XXXXXXXX
Run Code Online (Sandbox Code Playgroud)

Hus*_*bir 1

仅识别这段代码后不确定。但崩溃信号(SIGSEGV)似乎是由于内存泄漏造成的。您只需转到 Xcode 设置并在“编辑方案”内启用 Zombie 选项,然后尝试重现崩溃。它将向您显示方法的控制器类名称或 Xcode 控制台内的任何崩溃相关信息。并且尝试修改以下条件:-

- (void)setHighlighted:(BOOL)highlighted {

     //just comment this line or write this line to the below and check
     //[super setHighlighted:highlighted];
    if (highlighted) {
        self.alpha = 0.8;
    } else {
        self.alpha = 1.0;
    }
    [super setHighlighted:highlighted];
}
Run Code Online (Sandbox Code Playgroud)