开发者

what is absolute url of an image for showing as webView(loadHTMLString) in objective c

i am new in objective c. i want to show an image (this image is in re开发者_开发技巧sources->images->a.png). Now i want to show it as loadHTMLString formate. so what will be the image path? i have used "images\a.png" as src; but does not show the image.


[webView loadHTMLString:htmlString baseURL:[[NSBundle mainBundle] baseURLWithPrefix:@"file:"]];

that should work for you, provided your htmlString contain reference to your image similar to:

<img src=\"a.png\"/>


Finally I have got the answer:

NSString *path = [[NSBundle mainBundle] bundlePath];
NSURL *baseURL = [NSURL fileURLWithPath:path];

[webView loadHTMLString:htmlString baseURL:baseURL];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜