UIWebView does not show images on iOS9, and Safari

2019-06-25 05:28发布

问题:

Just found that UIWebView that load HTML string with images embedded does not work correctly to show the image on iOS9 (GM seed), which worked correctly previously on iOS8.

After viewed the WWDC SafariViewController video here and thought Apple wants us to turn to the new framework, which looks quite promising. But problem is SafariViewController does not support loading local HTML files and it only supports HTTP and HTTPS, so far on iOS9 GM seed and Xcode 7.1 beta. I tried to load it using NSURL pointing to the local file, exception thrown:

'NSInvalidArgumentException', reason: 'The specified URL has an unsupported scheme. Only HTTP and HTTPS URLs are supported'

Does anyone see same issue with UIWebView on iOS9 and any walkaround? Thanks.

About SafariViewController issue, I have pinged Ricky at Apple about this and filed a feature request, hopefully this will be addressed soon.

回答1:

You should be able to still use UIWebView and turn off the App Transport Security by setting the following in your plist file:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

Check out this answer for more help.