Is it possible to opt into iOS 13's 3-finger undo/redo gestures for a whole UICollectionViewController
(or UIViewController
/UITableViewController
)?
I have a UIDocument which is tracking changes via it's undoManager
and I currently call undo
/redo
on this. However I would like to opt in to allow 3-finger swipes/3-finger double tap/command + z to allow undo to be called and show the new overlay that text views pop-up when you undo/redo.
I've tried setting editingInteractionConfiguration
to default
on my view controller, which didn't seem to do anything.
Is this possible?
There are two steps that I needed to do here to make this work. The first was to return my document's undo manager as the view controller's undo manager with the following:
override var undoManager: UndoManager? { return document.undoManager }
The second was to make the view controller become the first responder, as advised in NSHipster's NSUndoManager article in the section about responding to the older shake gesture:
override var canBecomeFirstResponder: Bool { true }
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
becomeFirstResponder()
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
resignFirstResponder()
}
I'm still looking for additional code to ensure that the view controller regains it's first responder status after presenting an alert controller containing a text field, but that is realistically a different issue.