不太可能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
}