迅速uiwebview目标空白链接野生动物园

时间:2018-06-30 13:12:07

标签: swift xcode uiwebview

我只想在野生动物园中打开带有目标空白功能的链接。但是,通过此代码博客,所有链接都可以在野生动物园中打开。迅速和iOS 11。

import UIKit
import WebKit
class ViewController: UIViewController, UIWebViewDelegate {
@IBOutlet weak var tarayici: UIWebView!
override func viewDidLoad() {
    super.viewDidLoad()
 let url = URL(string:"http://www.website.com/ios.html")
    tarayici.loadRequest(URLRequest(url: url!))
    self.tarayici.delegate = self
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}
func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool {

    if navigationType == UIWebViewNavigationType.linkClicked {
        UIApplication.shared.openURL(request.url!)
        return false
    } 
    return true
}
}

1 个答案:

答案 0 :(得分:0)

我仍然没有得到结果。您在共享信息吗?