From 0aa3a9ea66a1f3f17666d4afdec0a1576632d6d5 Mon Sep 17 00:00:00 2001 From: mattwritescode Date: Tue, 20 Mar 2018 14:22:47 -0500 Subject: [PATCH] Display local files properly See Issue #43 --- SwiftWebVC/SwiftWebVC.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/SwiftWebVC/SwiftWebVC.swift b/SwiftWebVC/SwiftWebVC.swift index 584e273..cebe0ac 100755 --- a/SwiftWebVC/SwiftWebVC.swift +++ b/SwiftWebVC/SwiftWebVC.swift @@ -107,7 +107,13 @@ public class SwiftWebVC: UIViewController { } func loadRequest(_ request: URLRequest) { - webView.load(request) + if let url = request.url, + url.absoluteString.contains("file:"), + #available(iOS 9.0, *) { + webView.loadFileURL(url, allowingReadAccessTo: url) + } else { + webView.load(request) + } } ////////////////////////////////////////////////