不太可能 UITableViewCell、UICollectionViewCell 缺少setEditing:animated:和editing属性。
这是设计使然吗?Apple 是否强制执行其他最佳实践来处理 UICollectionView 及其单元格中的编辑?
不太可能 UITableViewCell、UICollectionViewCell 缺少setEditing:animated:和editing属性。
这是设计使然吗?Apple 是否强制执行其他最佳实践来处理 UICollectionView 及其单元格中的编辑?
也许这就是你需要的:
子类 UICollectionViewController 像ABCCollectionViewController:
let vc = UINavigationController(rootViewController: ABCCollectionViewController())
然后viewDidLoad在ABCCollectionViewController:
self.navigationItem.leftBarButtonItem = self.editButtonItem
然后重写 setEditting 方法:
override func setEditing(_ editing: Bool, animated: Bool) {
super.setEditing(editing, animated: true)
// Use these methods to do the edit things, without test but should works
collectionView?.beginInteractiveMovementForItem(at: indexPath)
print("editting")//Do some edit thing
collectionView?.endInteractiveMovement()
collectionView.updateInteractiveMovementTargetPosition()
collectionView?.cancelInteractiveMovement()
}
然后你可以调用:
setEditing(true, animated: true)
allowsMultipleSelection如果您在编辑时更改某些状态UICollectionView:
override func setEditing(_ editing: Bool, animated: Bool) {
super.setEditing(editing, animated: animated)
collectionView.allowsMultipleSelection = editing
}
您可以简单地将其添加到您的UICollectionViewCell子类中:
var isEditing: Bool {
return (superview as! UICollectionView).allowsMultipleSelection
}