Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't display local files properly #43

Open
mattwritescode opened this issue Mar 16, 2018 · 1 comment
Open

Doesn't display local files properly #43

mattwritescode opened this issue Mar 16, 2018 · 1 comment

Comments

@mattwritescode
Copy link

When trying to display a local file like this url: "file:///var/mobile/Containers/Data/Application/blahblahblah/downloads/15212173031370-A8AB82E7-A719-4148-89CE-D5CE9FD468C6.jpg" it doesn't display anything. This is related to an old WKWebView bug that has since been fixed back in iOS 9.
It requires that we load the url with
webView.loadFileURL(url, allowingReadAccessTo: url)
instead of
webView.load(request)

I've managed to find a spot to drop that in that works, but is a little ugly and probably doesn't match the organization of the existing code very well.

If you drop the following code in right here it fixes things.

func loadRequest(_ request: URLRequest) {
        if let url = request.url,
            url.absoluteString.contains("file:"),
            #available(iOS 9.0, *) {
                webView.loadFileURL(url, allowingReadAccessTo: url)
        } else {
            webView.load(request)
        }
}
mattwritescode added a commit to mattwritescode/SwiftWebVC that referenced this issue Mar 20, 2018
@peterdk
Copy link

peterdk commented Nov 19, 2019

We are running into the same issue and have spent hours on getting to understand why it did not load. I see the fix has been commited, so please release a new version to Cocoapods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants