Skip to content

Instantly share code, notes, and snippets.

@stevesohcot
Created May 8, 2016 17:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevesohcot/8bebbe4405c5994d193bac10563959a8 to your computer and use it in GitHub Desktop.
Save stevesohcot/8bebbe4405c5994d193bac10563959a8 to your computer and use it in GitHub Desktop.
Sample Webview using Swift with Progress Indicator
// http://stevesohcot.com/tech-lessons-learned/2016/05/08/webview-using-swift-with-progress-indicator-tutorial
import UIKit
class ViewController: UIViewController, UIWebViewDelegate {
@IBOutlet weak var webView: UIWebView!
@IBOutlet weak var progressIndicator: UIActivityIndicatorView!
override func viewDidLoad() {
super.viewDidLoad()
webView.delegate = self
let urlString = "https://hashtagsaver.herokuapp.com/login"
self.webView.loadRequest(NSURLRequest(URL:NSURL(string: urlString)!))
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
func webViewDidStartLoad(webView: UIWebView) {
progressIndicator.startAnimating()
}
func webViewDidFinishLoad(webView: UIWebView) {
progressIndicator.stopAnimating()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment