Reputation: 11722
After presenting SFSafariViewController modally, a user presses the "Done" button and the controller is dismissed with animation. If I implement the delegate and try to dismiss it without animation, it has no effect (still dismissed with animation):
let vc = SFSafariViewController(url: webUrl)
vc.delegate = self
self.present(vc, animated: true)
extension MyCoolViewController: SFSafariViewControllerDelegate {
func safariViewControllerDidFinish(_ controller: SFSafariViewController) {
controller.dismiss(animated: true)
}
}
If I try to dismiss the controller programmatically, it works just great and the animated
flag is honored but it I try to do it in the safariViewControllerDidFinish
, the animation is playing regardless.
Is it possible to override that behavior and dismiss the SFSafariViewController without animation when a user taps the "Done" button?
Upvotes: 0
Views: 121
Reputation: 9161
I've tried dismiss(_:)
, but it seems like it did not have any effect on dismiss style as normal. There is another approach, it's handling transitioningDelegate
by yourself:
let vc = SFSafariViewController(url: webUrl)
vc.transitioningDelegate = self
...
extension MyCoolViewController: UIViewControllerTransitioningDelegate {
func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
dismissed.view.alpha = 0
return .none
}
}
Output:
Upvotes: 1