Objective c UIWebView为空,并且未从资源加载图像

Objective c UIWebView为空,并且未从资源加载图像,objective-c,image,uiwebview,Objective C,Image,Uiwebview,我使用以下代码在UIWebView中显示图像: -(void)showImageWithLoadRequest{ NSString *path = [[NSBundle mainBundle] pathForResource:@"accent" ofType:@"png"]; NSURL *imageUrl = [NSURL fileURLWithPath:path]; NSURLRequest *imageRequest = [NSURLRequest requestW

我使用以下代码在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];
}
问题是,当我在模拟器中打开应用程序时,它会显示一个空白的UIWebView,没有任何图像

有什么办法解决这个问题吗? 我需要从我的资源中加载图像。在我的参考资料中,我有两个图像本地化。这可能是问题所在

编辑

正如Seamus所建议的,现在我使用:

NSString *path = [[NSBundle mainBundle] pathForResource:@"accent" ofType:@"png"];
[myWebView loadHTMLString:[NSString stringWithFormat:@"<html><body><img src=\"file://%@\"></body></html>",path] baseURL:nil];
但它仍然显示一个空白的网络视图。有什么想法吗?

我用html做这个。 uiwebview加载HtmlString:baseURL:

您可以将htmlSourceCode设置为:

htmlSourceCode = [[NSString alloc] initWithString:@"<html><body><img scr='file://%@'></body></html>",[img path]];
[webview loadHTMLString:htmlSourceCode baseURL:nil];

所以,我使用的代码是:NSString*path=[[NSBundle mainBundle]pathForResource:@testoftype:@png];[myWebView loadHTMLString:[NSString stringWithFormat:@,path]baseURL:nil];但它仍然显示了一个空白窗口!它没有加载图像。知道吗?@Pheel check accent.png是否存在。如果不使用ib,请检查webview.frame。