Skip to content

Instantly share code, notes, and snippets.

@KentarouKanno
Last active May 10, 2018 23:56
Show Gist options
  • Save KentarouKanno/81b1d1facfa41cae4da2 to your computer and use it in GitHub Desktop.
Save KentarouKanno/81b1d1facfa41cae4da2 to your computer and use it in GitHub Desktop.
UIWebView

UIWebView Template

import UIKit

class ViewController: UIViewController, UIWebViewDelegate {
    
    @IBOutlet weak var webView: UIWebView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        webView.delegate = self
        
        if let url = URL(string: "http://apple.com") {
            let urlRequest = URLRequest(url: url)
            webView.loadRequest(urlRequest)
        }
        
    }
    
    func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool {
        return true
    }
    
    func webViewDidStartLoad(_ webView: UIWebView) {
        
    }
    
    func webViewDidFinishLoad(_ webView: UIWebView) {
        
    }
    
    func webView(_ webView: UIWebView, didFailLoadWithError error: Error) {
        
    }
}

WebView Image

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment