Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift3 Swift 3.0迁移后UICollectionViewCell重新排序期间崩溃_Swift3_Uicollectionview_Uicollectionviewlayout - Fatal编程技术网

Swift3 Swift 3.0迁移后UICollectionViewCell重新排序期间崩溃

Swift3 Swift 3.0迁移后UICollectionViewCell重新排序期间崩溃,swift3,uicollectionview,uicollectionviewlayout,Swift3,Uicollectionview,Uicollectionviewlayout,在应用程序的UICollectionView中使用重新排序功能时,我确实遇到了一个奇怪的问题。我们有一个自定义布局,用于显示装饰视图。集合视图使用基于流的布局。当我将第一个单元格从其位置移动到最后一个单元格位置以重新排序单元格时,应用程序在调用集合视图委托的collectionView(moveItemAt:to)方法之前崩溃 已附加此问题的堆栈跟踪。您可以看到,在NSIndexPath和IndexPath之间的桥接中发生了崩溃。我不知道为什么它发生在UIKit内部。搜索该问题时发现,它似乎是在

在应用程序的UICollectionView中使用重新排序功能时,我确实遇到了一个奇怪的问题。我们有一个自定义布局,用于显示装饰视图。集合视图使用基于流的布局。当我将第一个单元格从其位置移动到最后一个单元格位置以重新排序单元格时,应用程序在调用集合视图委托的
collectionView(moveItemAt:to)
方法之前崩溃

已附加此问题的堆栈跟踪。您可以看到,在NSIndexPath和IndexPath之间的桥接中发生了崩溃。我不知道为什么它发生在UIKit内部。搜索该问题时发现,它似乎是在Swift 3.0中引入的UIKIt中的错误。我测试了我的旧版本,它是在swift 3.0迁移之前构建的,可以正常工作,没有任何崩溃

有人能告诉我如何解决这个问题吗

相关错误链接


添加您当前正在尝试的代码。一旦用户结束拖动单元格并将手指从设备上提起,将调用UIGestureRecognitizerState.ended开关,该开关将依次调用collectionview(moveItemAt:to)API。@NiravD:您知道此问题和可能的解决方案吗?是否调用了
HandleLongship
方法?放置断点并检查一次,因为很难从这种类型的崩溃日志中判断崩溃原因。是的,正在调用它。
func handleLongGesture(_ gesture: UILongPressGestureRecognizer) {

    switch(gesture.state) {

    case UIGestureRecognizerState.began:
        if let movingPageIndexPath = collectionView.indexPathForItem(at: gesture.location(in: collectionView)) {
            collectionView.beginInteractiveMovementForItem(at: movingPageIndexPath)
        }

    case UIGestureRecognizerState.changed:
        collectionView.updateInteractiveMovementTargetPosition(gesture.location(in: collectionView))

    case UIGestureRecognizerState.ended:
        collectionView.endInteractiveMovement()

    default:
        collectionView.cancelInteractiveMovement()
    }
}