Ale*_*nov 7 drag-and-drop uicollectionview swift
我使用拖放来重新排列 collectionView。当我开始拖动时,我更改了 collectionView 可视化。要将它改回来,我需要一个在任何情况下都会执行的方法。现在,如果我开始拖动并立即释放触摸,则不会执行以下任何方法:
not this:
func collectionView(_ collectionView: UICollectionView, dragSessionDidEnd session: UIDragSession)
not this:
func collectionView(_ collectionView: UICollectionView, dropSessionDidEnd session: UIDropSession)
not this:
func collectionView(_ collectionView: UICollectionView, performDropWith coordinator: UICollectionViewDropCoordinator)
Run Code Online (Sandbox Code Playgroud)
谢谢你。
如果您使用标准 UICollectionViewDragDelegate 实现,您可以使用func dragStateDidChange(_ dragState: UICollectionViewCellDragState) 单元格类本身对单元格状态更改做出反应,如下所示:
override func dragStateDidChange(_ dragState: UICollectionViewCellDragState) {
switch dragState {
case .none:
//
case .lifting:
//
case .dragging:
//
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2523 次 |
| 最近记录: |