We have a local html to show in UIWebView
. And there, we want to show images that are defined in Asset Catalog.
I know that we can do similar thing if we had the image flat in the main bundle. The code snippet would be like this.
webView.loadHTMLString("<img src='target_image.png'/>", baseURL: NSBundle.mainBundle().bundleURL)
However, I am not sure what I can specify for "target_image.png" if the png file is packaged in asset catalog. (Furthermore, we want to specify pdf to take advantage of vector image support in Xcode 6)
Does anybody have any idea how to achieve this?
NSURLProtocol
and return corresponding UIImage in the asset catalog from there, I see. That's very interesting idea! Never came to me. However, the obvious drawback is that it affects NSURLRequest application wide, and not very practical for my app and probably most of the apps :( Having said that, thanks for a new perspective! – Advocate