小编A.D*_*aro的帖子

在 UIWebView 中成功登录后如何重定向回应用程序

我正在使用带有 UIWebView 的 UIViewController。在此 UIWebView 中,用户必须登录,成功登录后,应将用户重定向回应用程序。但就我而言,它保留在 UIWebView 中并且不会将我重定向回应用程序。

我尝试在 API Delegate 中使用此代码:

func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
    DispatchQueue.main.async {
        if (url.scheme == "go-back"){
            let storyboard = UIStoryboard(name: "Main", bundle: nil)
            let controller = storyboard.instantiateViewController(withIdentifier: "WebView") as! ViewController
            self.window?.rootViewController!.present(controller, animated: true, completion: { () -> Void in
            })
        }
    }
    return true
}
Run Code Online (Sandbox Code Playgroud)

并创建了一个 URL 方案,但它不起作用。

uiwebview uiviewcontroller ios uistoryboard swift

1
推荐指数
1
解决办法
4987
查看次数

标签 统计

ios ×1

swift ×1

uistoryboard ×1

uiviewcontroller ×1

uiwebview ×1