I start Safari in an application and want to execute my code after I press Done. But the function func safariViewControllerDidFinish
won't go into.
import SafariServices
class QRScannerController: UIViewController, WKNavigationDelegate, SFSafariViewControllerDelegate {
let vc = SFSafariViewController (url: URL(string: String(urls))!)
present(vc, animated: true, completion: nil)
vc.delegate = self
func safariViewControllerDidFinish(_ controller: SFSafariViewController) {
controller.dismiss(animated: true) {
// do my code
}
CodePudding user response:
You don't need to dismiss the controller inside safariViewControllerDidFinish
, it is already dismissed when done is tapped.
import SafariServices
class QRScannerController: UIViewController, SFSafariViewControllerDelegate {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
let vc = SFSafariViewController (url: URL(string: "https://www.google.com")!)
self.present(vc, animated: true, completion: nil)
vc.delegate = self
}
func safariViewControllerDidFinish(_ controller: SFSafariViewController) {
// do your code
print("done!")
}
}