本文介绍了未调用UIWebView webViewDidLoadFinish方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我今天晚上一直在玩网络浏览器,但是遇到了一些问题。
I've been playing around with web views in swift this evening, but have run into a bit of an issue.
由于某些原因,我无法进行获取要触发的webViewDidStartLoad或webViewDidFinishLoad方法。
在我的故事板中,我有一个名为webView的插座链接到我的UIWebView元素。
For some reason I'm not able to get the webViewDidStartLoad or webViewDidFinishLoad methods to fire.In my storyboard, I have an outlet called webView linked to my UIWebView element.
是否有人能够帮助我解决我的错误?
Is anyone able to help me with what I am doing wrong?
这是我的viewController.swift文件:
This is my viewController.swift file:
import UIKit
class ViewController: UIViewController, UIWebViewDelegate {
@IBOutlet var webView : UIWebView
var url = NSURL(string: "http://google.com")
override func viewDidLoad() {
super.viewDidLoad()
//load initial URL
var req = NSURLRequest(URL : url)
webView.loadRequest(req)
}
func webViewDidStartLoad(webView : UIWebView) {
//UIApplication.sharedApplication().networkActivityIndicatorVisible = true
println("AA")
}
func webViewDidFinishLoad(webView : UIWebView) {
//UIApplication.sharedApplication().networkActivityIndicatorVisible = false
println("BB")
}
}
推荐答案
试试这个!
var req = NSURLRequest(URL: url)
webView.delegate = self
webView.loadRequest(req)
这篇关于未调用UIWebView webViewDidLoadFinish方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!