完全加载后获取 url SFSafariViewController

Jos*_*Fit 8 ios swift sfsafariviewcontroller

我正在使用 SFSafariViewController。加载的初始 url 重定向到另一个 url。我需要获取 SFSafariViewController 具有的当前 url 栏。

它成功重定向,因为我可以在 url 栏中看到它,但我什至无法从委托方法中访问它。

在此之前,我使用 UIWebView 并且它工作正常但突然它不再重定向了。

这是我的 SFSafariViewController 代码:

    override func viewDidAppear(_ animated: Bool) {

    safari = SFSafariViewController(url: URL(string:"https://api.instagram.com/oauth/authorize/?client_id=client_code&redirect_uri=http://localhost&response_type=code")!)

    safari.delegate = self

    self.present(safari, animated: true, completion: nil)

}
Run Code Online (Sandbox Code Playgroud)

它显示正确,但我需要访问当前 url。

提前致谢。