简体   繁体   中英

Thread 1: EXEC_BAD_ACCESS (code=1) when dismissing view controller with collection

I've posted this issue directly on the library's github page ( https://github.com/lxcid/LXReorderableCollectionViewFlowLayout/issues/43 ) but I thought I would get more exposure here.

I've implemented the library as follows:

LXReorderableCollectionViewFlowLayout *layout = [[LXReorderableCollectionViewFlowLayout alloc] init];
[collection setCollectionViewLayout:layout];

Where collection is a UICollectionView inside a UIViewController that I manually segue to. The dragging and dropping and reordering works fine with the itemAtIndexPath:fromIndexPath willMoveToIndexPath:toIndexPath function.

However, as soon as I dismiss the view controller with:

[self dismissViewControllerAnimated:YES completion:nil];

I'm hit with the Thread 1: EXEC_BAD_ACCESS (code=1) error.

The error is occuring here:

@autoreleasepool {
    return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}

and bt is showing:

frame #0: 0x019130b2 libobjc.A.dylib`objc_msgSend + 14
frame #1: 0x01bab735 CoreFoundation`-[NSSet makeObjectsPerformSelector:withObject:] + 277
frame #2: 0x0087f902 UIKit`-[UIGestureRecognizer dealloc] + 127
frame #3: 0x008952a5 UIKit`-[UILongPressGestureRecognizer dealloc] + 174

A similar issue someone else is having ( https://github.com/lxcid/LXReorderableCollectionViewFlowLayout/issues/32 ) has a response:

The crash occurs because the gesture recognizers that have been setup on the collection view are never removed when the layout is removed from the collection view. So when a gesture occurs, the recognizer tries to call the delegate method gestureRecognizerShouldBegin: on the layout which has by now been deallocated.

But I'm unsure what that means or what to do to fix it, if it is the same issue.

Any help is greatly appreciated.

I'm still unsure what caused this, but I solved this issue by changing to the github source instead of using cocoapods. My cocoapod version was 0.1.0.beta1 (which I got from https://www.cocoacontrols.com/controls/lxreorderablecollectionviewflowlayout ), I'm guessing it was very out of date.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM