重新排序iOS 11的CollectionView单元

Ant*_*ony 5 objective-c ios swift ios11

我知道iOS 11为collectionview带来了新的拖放功能,但是使用它存在一个完全独立的问题。所以我想我会尝试使用IOS 9中引入的旧方法(请参阅此链接)。我的问题是,在iOS 11上,仅当切换两个单元格时,手指移开时的结束动画效果才怪异。您可以在此剪辑中看到问题。

我已经尝试了好几天了,没有运气。它可以在iOS 10上正常运行,但不能在iOS 11上运行。任何帮助将不胜感激。

额外信息:我正在使用带有长按手势的collectionview来启动重新排序手势,如第一个链接所示。但是,使用uicollectionviewcontroller时仍然会出现问题

这是长按手势的代码:

func handleLongGesture(gesture: UILongPressGestureRecognizer) {

    switch(gesture.state) {

    case .began:
        guard let selectedIndexPath = self.collectionView.indexPathForItem(at: gesture.location(in: self.collectionView)) else {
            break
        }
        collectionView.beginInteractiveMovementForItem(at: selectedIndexPath)
    case .changed:
        collectionView.updateInteractiveMovementTargetPosition(gesture.location(in: gesture.view!))
    case .ended:
      // this part misbehaves on ios 11 when two cells are swapped
        collectionView.performBatchUpdates({
            self.collectionView.endInteractiveMovement()
        )}
    default:
        collectionView.cancelInteractiveMovement()
    }
}
Run Code Online (Sandbox Code Playgroud)

Vic*_*tor 0

无需self.collectionView.endInteractiveMovement()在performBatchUpdates 块内执行操作。