【发布时间】:2019-02-05 07:24:18
【问题描述】:
在 xCode 中,我同时添加了活动指示器和 UIWebView 方面,但是在网页加载后活动指示器不会隐藏。这是代码,有什么提示可以让它工作吗?
override func viewDidLoad(){
super.viewDidLoad()
Videoview.delegate = self as? UIWebViewDelegate;
loadAdress()
}
func loadAdress() {
let requestURL = NSURL(string: "https://twitter.com/")
let request = NSURLRequest(url: requestURL! as URL)
Videoview.loadRequest(request as URLRequest)
}
func webViewDidStartLoad(_ : UIWebView) {
ActvityView.startAnimating()
NSLog("The webview is started loading")
}
func webViewDidStopLoad(_ : UIWebView) {
ActvityView.stopAnimating()
ActvityView.isHidden=true;
NSLog("The webview is done loading")
}
func WebViewActvityStopError(_ : UIWebView, didFailLoadWithError error: Error){
ActvityView.stopAnimating()
ActvityView.isHidden=true;
print("Webview fail with error \(error)");
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
谢谢:)
【问题讨论】:
-
您错过了 webViewDidFinishLoad 委托方法。
标签: ios iphone xcode uiwebview uiactivityindicatorview