0
我在下面试过两种方法,但只有白色背景出现,没有图像显示。如何在UIWebView中加载图像
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];
我认为都是正确的方法,但都是无用的我。 Plz帮助我。
ya thanku.But我完成了第二种方法,我在做一个愚蠢的错误。 –