//
// ViewController.swift
// TestApp2
//
// Created by Divakar Singh on 3/7/17.
// Copyright (c) 2017 Divakar Singh. All rights reserved.
//
import UIKit
class ViewController: UIViewController, UIWebViewDelegate {
private var myWebView: UIWebView!
override func viewDidLoad() {
super.viewDidLoad()
// create webview.
myWebView = UIWebView()
// set delegate
myWebView.delegate = self
// set size
myWebView.frame = self.view.bounds
// add it to the view.
self.view.addSubview(myWebView)
// set URL
let url: NSURL = NSURL(string: "http://www.apple.com")!
// make a request
let request: NSURLRequest = NSURLRequest(URL: url)
// load the request on webview
myWebView.loadRequest(request)
}
// Delegate method of webview which is called when finish loading
func webViewDidFinishLoad(webView: UIWebView) {
print("webViewDidFinishLoad")
}
// Delegate method of webview which is called when start loading
func webViewDidStartLoad(webView: UIWebView) {
print("webViewDidStartLoad")
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
No comments:
Post a Comment