Fix crash with large image dismiss gesture

This commit is contained in:
Shadowfacts 2023-10-28 13:58:39 -05:00
parent 3aa45cb365
commit af5a0b7bbd
1 changed files with 9 additions and 2 deletions

View File

@ -25,7 +25,14 @@ class LargeImageInteractionController: UIPercentDrivenInteractiveTransition {
}
@objc func handleGesture(_ recognizer: UIPanGestureRecognizer) {
let translation = recognizer.translation(in: recognizer.view!.superview!)
guard let recognizerSuperview = recognizer.view?.superview else {
// Assume the gesture has ended b/c we don't have a view/superview anymore.
inProgress = false
direction = nil
cancel()
return
}
let translation = recognizer.translation(in: recognizerSuperview)
var progress = translation.y / 200
if let direction = direction {
progress *= direction
@ -63,7 +70,7 @@ class LargeImageInteractionController: UIPercentDrivenInteractiveTransition {
override func cancel() {
super.cancel()
viewController.isInteractivelyAnimatingDismissal = false
viewController?.isInteractivelyAnimatingDismissal = false
}
}