I'm a newbie on IOS development. Recently, I use UIWebView
to load a webpage, and this is successful, and try to open links in it on the same UIWebView instance. However, after a click on some link, there's no response from UIWebView
, and in xcode, it reports
2015-03-29 23:42:07.246 xxxxx[17349:1251340] Unknown result for URL http://www.xxxxxx.org/bugs/xxxxxx-xxxx-xxxxxx, for frame
I looked it up on Internet but I got little useful help. I know someone said to implement func webView in UIWebViewDelegate, but my app still doesn't work.
Can someone help me? I'm using the latest version of swift language. And a snippet of code is :
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.
}
}