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
Post a Comment