-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWebViewController.swift
More file actions
52 lines (35 loc) · 1.26 KB
/
Copy pathWebViewController.swift
File metadata and controls
52 lines (35 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//
// WebViewController.swift
// SimpleWebView
//
// Created by iwritecode on 4/5/16.
// Copyright © 2016 sojiwritescode. All rights reserved.
//
import UIKit
class WebViewController: UIViewController {
@IBOutlet weak var webView: UIWebView!
@IBOutlet weak var addressBar: UISearchBar!
@IBOutlet weak var activityIndicator: UIActivityIndicatorView!
override func viewDidLoad() {
super.viewDidLoad()
let url = NSURL(string: "http://apple.com")
let urlRequest = NSURLRequest(URL: url!)
webView.loadRequest(urlRequest)
addressBar.text = "http://"
}
func searchBarSearchButtonClicked(searchBar: UISearchBar!) {
searchBar.resignFirstResponder()
let url = NSURL(string: addressBar.text!)
let request = NSURLRequest(URL: url!)
webView.loadRequest(request)
}
func webviewDidStartLoad(_ : UIWebView) {
activityIndicator.startAnimating()
}
func webviewDidFinishLoad(_ : UIWebView) {
activityIndicator.stopAnimating()
}
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
addressBar.resignFirstResponder()
}
}