Created
May 8, 2016 17:28
-
-
Save stevesohcot/8bebbe4405c5994d193bac10563959a8 to your computer and use it in GitHub Desktop.
Sample Webview using Swift with Progress Indicator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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