WkWebView and iOS9 still not loading images ("file://") - allowingReadAccessToURL
Asked Answered
W

0

8

i'm still having trouble reading local files using WKWebView on iOS9. My App is taking pictures (camera) and stores them in a structured path in the DOCUMENTS folder.

Later i want to display these pictures using a WKWebView. My local .html file has placeholders for the images which will be replaced with the corresponding fileURLs.

Code:

        NSString *directory = image.field.imagesDirectory;
        NSURL *fileURL = [NSURL fileURLWithPath:[directory stringByAppendingPathComponent:image.fileName]];
        [self.webView loadFileURL:fileURL allowingReadAccessToURL:[NSURL fileURLWithPath:directory isDirectory:YES]];

fileURL will be used later to replace the ing-placeholders in the HTML-file

Code:

    NSString *containter = [imageContainer stringByReplacingOccurrencesOfString:@"##IMGSOURCE##" withString:fileURL.absoluteString];

This works in the simulator like a charm, but fails on a real device without giving any hints.

Any ideas??

Cheers,

Michael

Waldman answered 20/8, 2016 at 8:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.