Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. //
  2. // ViewController.swift
  3. // Honk
  4. //
  5. // Created by Nick Gressle on 9/23/17.
  6. // Copyright © 2017 nick gressle illustrations llc. All rights reserved.
  7. //
  8.  
  9. import UIKit
  10. import WebKit
  11.  
  12. class ViewController: UIViewController, WKNavigationDelegate {
  13. override func viewDidLoad() {
  14. super.viewDidLoad()
  15. let webView = WKWebView()
  16. let htmlPath = Bundle.main.path(forResource: "Honk", ofType: "html")
  17. let folderPath = Bundle.main.bundlePath
  18. let baseUrl = URL(fileURLWithPath: folderPath, isDirectory: true)
  19. do {
  20. let htmlString = try NSString(contentsOfFile: htmlPath!, encoding: String.Encoding.utf8.rawValue)
  21. webView.loadHTMLString(htmlString as String, baseURL: baseUrl)
  22. } catch {
  23. // catch error
  24. }
  25. webView.navigationDelegate = self
  26. view = webView
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement