Có lẽ đây là những gì bạn cần:
Subclass UICollectionViewController như ABCCollectionViewController
:
let vc = UINavigationController(rootViewController: ABCCollectionViewController())
Sau đó, trong viewDidLoad
của ABCCollectionViewController
:
self.navigationItem.leftBarButtonItem = self.editButtonItem
Sau đó chép đè phương thức 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()
}
Sau đó, bạn có thể gọi:
setEditing(true, animated: true)
Nguồn
2017-11-09 09:01:03