簡體   English   中英

`如何在具有最新快速版本的UIWebView中打開鏈接

[英]`how to open a link in a UIWebView with latest swift version

我是IOS開發的新手。 最近,我使用UIWebView加載網頁,並且成功,並嘗試在同一UIWebView實例上打開其中的鏈接。 但是,單擊某些鏈接后, UIWebView沒有響應,並且在xcode中,它報告

2015-03-29 23:42:07.246 xxxxx [17349:1251340]網址為http://www.xxxxxx.org/bugs/xxxxxx-xxxx-xxxxxx的未知結果

我在Internet上進行了查詢,但沒有什么有用的幫助。 我知道有人說過要在UIWebViewDelegate中實現func webView,但是我的應用仍然無法正常工作。

有人能幫我嗎? 我正在使用最新版本的Swift語言。 一段代碼是:

 import UIKit

class ViewController: UIViewController, UIWebViewDelegate {

    @IBOutlet weak var front: UIWebView!

    func webView(webView: UIWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType nt: UIWebViewNavigationType) -> Bool {

    if (nt ==.LinkClicked){
        return true
    }
    return true;
}

override func viewDidLoad() {
    super.viewDidLoad()
    UIWebView.loadRequest(self.front)(NSURLRequest(URL: NSURL(string: "http://www.google.com")!))        // Do any additional setup after loading the view, typically from a nib.
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

}

這是示例代碼:

UIWebView.loadRequest(webviewInstance)(NSURLRequest(URL: NSURL(string: "www.google.in")))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM