forked from shadowfacts/Tusker
Fix crash due to PencilKit undo manager not being available until viewDidAppear
This commit is contained in:
parent
2a05b6d326
commit
7c9287543c
|
@ -80,13 +80,14 @@ class ComposeDrawingViewController: UIViewController {
|
||||||
|
|
||||||
updateLayout(for: toolPicker)
|
updateLayout(for: toolPicker)
|
||||||
canvasView.becomeFirstResponder()
|
canvasView.becomeFirstResponder()
|
||||||
|
}
|
||||||
|
|
||||||
|
override func viewDidAppear(_ animated: Bool) {
|
||||||
|
super.viewDidAppear(animated)
|
||||||
|
|
||||||
// wait until the next run loop iteration so that the canvas view has become first responder and it's undo manager exists
|
|
||||||
DispatchQueue.main.async {
|
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(self.updateUndoRedoButtonState), name: .NSUndoManagerDidUndoChange, object: self.undoManager!)
|
NotificationCenter.default.addObserver(self, selector: #selector(self.updateUndoRedoButtonState), name: .NSUndoManagerDidUndoChange, object: self.undoManager!)
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(self.updateUndoRedoButtonState), name: .NSUndoManagerDidRedoChange, object: self.undoManager!)
|
NotificationCenter.default.addObserver(self, selector: #selector(self.updateUndoRedoButtonState), name: .NSUndoManagerDidRedoChange, object: self.undoManager!)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
func updateLayout(for toolPicker: PKToolPicker) {
|
func updateLayout(for toolPicker: PKToolPicker) {
|
||||||
let obscuredFrame = toolPicker.frameObscured(in: view)
|
let obscuredFrame = toolPicker.frameObscured(in: view)
|
||||||
|
|
Loading…
Reference in New Issue