我尝试了以下两种方法,但只出现白色背景,没有显示图像。
1.
NSString *path = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"png"];
[myWebView loadHTMLString:[NSString stringWithFormat:@"<html><body><img src=\"file://%@\"></body></html>",path] baseURL:nil];
2.
NSString *path = [[NSBundle mainBundle] pathForResource:@"yourImage" ofType:@"png"];
//Creating a URL which points towards our path
NSURL *url = [NSURL fileURLWithPath:path];
//Creating a page request which will load our URL (Which points to our path)
NSURLRequest *request = [NSURLRequest requestWithURL:url];
//Telling our webView to load our above request
[webView loadRequest:request];
我认为这两种方法都是正确的,但对我来说都没有用。请帮帮我。