我正在尝试使用ActivityIndicator向用户显示网站正在加载,但ActivityIndicator将永远不会出现。它应该在网站加载时旋转,并在网站完成时停止并隐藏。我是否必须将指示器连接到delage或其他东西。这是我的代码全部在swift。
//
// WebsiteViewController.swift
// ParseStarterProject-Swift
//
// Created by Lucas on 1/10/16.
// Copyright © 2016 Parse. All rights reserved.
//
import UIKit
class WebsiteViewController: UIViewController, UIWebViewDelegate {
@IBOutlet var Active: UIActivityIndicatorView!
@IBOutlet var webView: UIWebView!
override func viewDidLoad() {
super.viewDidLoad()
let url = NSURL(string: "http://www.google.com")!
webView.delegate = self
webView.loadRequest(NSURLRequest(URL: url))
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func webViewDidStartLoad(webView: UIWebView)
{
Active.startAnimating()
}
func webViewDidFinishLoad(webView: UIWebView)
{
Active.stopAnimating()
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}