Xcode, Swift; Detect hyperlink click in UIWebView

前端 未结 3 1213
予麋鹿
予麋鹿 2021-01-13 06:57

I made an iOS app with Xcode and Swift.

I want to open specific hyperlinks in Safari browser, there others in the WebView itself.

To reach this, I\'ll have t

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-13 07:04

    please try

    for swift 3.0

     public func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool
            {
             if navigationType == .linkClicked
             {
    
                }
                return true;
            }
    

    swift 2.2

    internal func webView(webView: UIWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType: UIWebViewNavigationType) -> Bool
        {
            if navigationType == .LinkClicked
            {
    
            }
            return true;
        }
    

提交回复
热议问题