Ответ 1
Возможно, это то, что вам нужно:
Подкласс UICollectionViewController как ABCCollectionViewController
:
let vc = UINavigationController(rootViewController: ABCCollectionViewController())
Тогда в viewDidLoad
of 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)