ios - Loading a local image directly into a UIWebView without HTML? -


i'm trying load local image file uiwebview. necessary create html file , load image or can directly load image in web view?

this code i'm using load image web view, shows blank.

nsurl *url = [nsurl fileurlwithpath:localfilepath isdirectory:no]; nsurlrequest *request = [nsurlrequest requestwithurl:url]; [self.webview loadrequest:request]; 

uiwebview has loaddata:mimetype:textencodingname:baseurl: method. rather writing html image in it, simpler this

nsdata *imagedata = [nsdata datawithcontentsofurl:fileurl]; [self.webview loaddata:imagedata mimetype:@"image/..." textencodingname:@"utf-8" baseurl:nil]; 

the mimetype argument should changed whatever mime type image is. (e.g. jpeg image/jpeg)


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -