I’m using this code to display an image in an UIWebView:
-(void)showImageWithLoadRequest{
NSString *path = [[NSBundle mainBundle] pathForResource:@"accent" ofType:@"png"];
NSURL *imageUrl = [NSURL fileURLWithPath:path];
NSURLRequest *imageRequest = [NSURLRequest requestWithURL:imageUrl];
web.scalesPageToFit = YES;
[web loadRequest:imageRequest];
}
The problem is that when i open up the app in the simulator, it shows me a blank UIWebView, without any image.
Any ideas to solve that?
I need to load images from my Resources. And in my Resources i have 2 images localizations. It may be the problem?
EDIT
As Seamus suggested, now i’m using:
NSString *path = [[NSBundle mainBundle] pathForResource:@"accent" ofType:@"png"];
[myWebView loadHTMLString:[NSString stringWithFormat:@"<html><body><img src=\"file://%@\"></body></html>",path] baseURL:nil];
but it still shows me a blank WebView. Any ideas?
i do this use html.
uiwebview
loadHTMLString:baseURL:and you can set htmlSourceCode like: