Opening ViewController when click on button in UIWebView swift

后端 未结 2 1252
日久生厌
日久生厌 2021-02-06 17:34

I Have an app which has UIWebView and the Webview contains simple Button

and here\'s my WebViewController :

import UIKit

class testV         


        
2条回答
  •  时光说笑
    2021-02-06 17:52

    You can assign a scheme in the js action:

    window.location = yourscheme://
    

    and in swift layer you can use the callback:

    func webView(webView: UIWebView!, shouldStartLoadWithRequest request: NSURLRequest!, navigationType: UIWebViewNavigationType) -> Bool {
        if (request.URL.scheme == "yourscheme") {
            // Your code
        }
        return true;
    }
    

提交回复
热议问题