不太可能UITableViewCell,UICollectionViewCell缺少setEditing:animated:
和editing
属性。缺少编辑属性和setEditing:animated:在UICollectionViewCell
这是设计吗?苹果是否正在执行其他最佳做法来处理UICollectionView及其单元格中的编辑?
不太可能UITableViewCell,UICollectionViewCell缺少setEditing:animated:
和editing
属性。缺少编辑属性和setEditing:animated:在UICollectionViewCell
这是设计吗?苹果是否正在执行其他最佳做法来处理UICollectionView及其单元格中的编辑?
也许这就是你需要:
子类UICollectionViewController像ABCCollectionViewController
:
let vc = UINavigationController(rootViewController: ABCCollectionViewController())
然后在ABCCollectionViewController
viewDidLoad
:
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
}