Skip to content

Commit

Permalink
toViewControllerSnapshot fix
Browse files Browse the repository at this point in the history
toViewControllerSnapshot sometimes return nil, the library now will try to take a snapshot independent if the view is added to the screen or not, otherwise it will simply cancel the animation and remove the view controller.
  • Loading branch information
ppamorim authored Feb 28, 2020
1 parent f808c8e commit f9b542a
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,12 @@ public extension UIViewController {
fatalError("Error to take sel snapshot")
}

guard let toViewControllerSnapshot: UIView = self.presentingViewController?.view.snapshotView(afterScreenUpdates: true) else {
fatalError("Error to take snapshot of presentingViewController")
guard let toViewControllerSnapshot: UIView = self.presentingViewController?.view.snapshotView(afterScreenUpdates: true)
?? self.presentingViewController?.view.snapshotView(afterScreenUpdates: false) else {
self.dismiss(animated: false, completion: {
transitionCompletion?()
})
return
}

fromViewControllerSnapshot.isOpaque = true
Expand Down

0 comments on commit f9b542a

Please sign in to comment.