当我到达某个页面时,我试图关闭 SFSafariViewController。
But I am unable to do it until the "Done" button is pressed explicitly by the user.
我想要的是在它到达某个页面时立即获取 URL,然后关闭 View Controller 。 然后我可以用这个挑选剩下的
func safariViewControllerDidFinish(_ controller: SFSafariViewController){
// do work here
}
Note: This question has been asked before but I was unable to find any satisfactory answers
最佳答案
也许已经晚了但我认为它会帮助任何人搜索相同的问题 监听 SFSafariViewControllerDelegate 委托(delegate)你可以在里面使用这个方法
func safariViewController(_ controller: SFSafariViewController, initialLoadDidRedirectTo URL: URL) {}
在它里面你可以在你的特定页面上设置你需要采取行动的条件......例如,如果我想在到达特定页面时关闭它,我会这样做
func safariViewController(_ controller: SFSafariViewController, initialLoadDidRedirectTo URL: URL) {
if URL.absoluteString == "WHATEVER YOUR LINK IS"{
controller.dismiss(animated: true, completion: nil)
}
}
关于ios - 在某个 url 上关闭 SFSafariViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47259647/