lxcid/LXReorderableCollectionViewFlowLayout

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

xelfer opened this issue · 5 comments

Not sure why this is happening, I've implemented as follows:

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

And 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.

Any ideas what I could be doing wrong here? The view worked perfectly before I implemented this.

Thanks.

may be

- (void)dealloc {
  collection.dataSource = nil;
  collection.delegate = nil;
}

you can set custom layout in storyboard (not programmatically)

Still appears to happen, sorry I should mention I'm using ARC (does that make a difference?).

Here's where I'm getting the error:

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

Could it be related to this? #32

edit: I believe it is, a backtrace 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

I'm unsure how to fix what that issue is suggesting however.

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.

I am still seeing this crash when dismissing a controller that has a custom collectionview subclass. Solution was to set self.gestureRecognizers=nil; in the collectionview dealloc.

Thank you xelfer for your comment, I did the same and I don't have the crash anymore. The cocoapods version needs to be updated probably.