简体   繁体   English

线程1:使用集合关闭视图控制器时,EXEC_BAD_ACCESS(code = 1)

[英]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. 我已经直接在库的github页面( https://github.com/lxcid/LXReorderableCollectionViewFlowLayout/issues/43 )上发布了此问题,但我想我会在这里得到更多的了解。

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. 其中collection是我手动选择的UIViewController内部的UICollectionView。 The dragging and dropping and reordering works fine with the itemAtIndexPath:fromIndexPath willMoveToIndexPath:toIndexPath function. 拖放和重新排序可以与itemAtIndexPath:fromIndexPath willMoveToIndexPath:toIndexPath函数一起正常使用。

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. 我被线程1击中:EXEC_BAD_ACCESS(code = 1)错误。

The error is occuring here: 错误发生在这里:

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

and bt is showing: 并且bt显示:

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: 其他人遇到的类似问题( https://github.com/lxcid/LXReorderableCollectionViewFlowLayout/issues/32 )也有响应:

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. 因此,当发生手势时,识别器会尝试在目前已取消分配的布局上调用委托方法gestureRecognizerShouldBegin:。

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. 我仍然不确定是什么原因造成的,但是我通过更改为github源而不是使用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. 我的cocoapod版本是0.1.0.beta1(我从https://www.cocoacontrols.com/controls/lxreorderablecollectionviewflowlayout获得 ),我猜它已经过时了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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