【发布时间】:2017-09-02 20:36:38
【问题描述】:
我知道 iOS 11 为 collectionview 带来了新的拖放功能,但我在使用它时遇到了一个完全不同的问题。所以我想我会尝试使用 IOS 9 (see this link) 中引入的旧方法。我的问题是,在 iOS 11 上,仅当切换两个单元格时,移除手指时的结束动画才会奇怪。你可以在这个clip看到问题。
几天来我一直在尝试解决这个问题,但没有运气。它在 iOS 10 上运行良好,但在 iOS 11 上运行良好。任何帮助将不胜感激。
额外信息:我正在使用带有长按手势的集合视图来启动重新排序手势,如第一个链接中所示。但是,在使用 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()
}
}
【问题讨论】:
-
请添加一些代码sn-ps来说明你的问题,让帮助你更容易。
-
我在水平的collectionview中遇到了完全相同的问题,但不是垂直的。你的是水平的吗?
-
这很奇怪……我的是垂直的
-
你解决过这个问题吗?我遇到了完全相同的问题。
-
更新:我在调用 endInteractiveMovement() 后无意中调用了 invalidateLayout()。 invalidateLayout() 给我造成了丑陋的动画故障。不调用 invalidateLayout() 似乎已经为我修复了它。
标签: ios objective-c swift ios11