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我完成了第二種方法,我在做一個愚蠢的錯誤。 –