在UIWebView中显示图像 [英] Displaying an image in UIWebView

查看:145
本文介绍了在UIWebView中显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在UIWebView中使用

 < img src =imageInBundle.png/> ; 

上面的图片在我的包中。我加载它,连同其他HTML在一个字符串,像这样:

  [myWebView loadHTMLString:htmlString baseURL:[NSURL URLWithString: @http://www.abc.com]]; 

但是,我只是得到一个带有白色问号的蓝色框。是否还有其他需要做的事?

解决方案

尝试更改

  [NSURL URLWithString:@http://www.abc.com] 

  [NSURL fileURLWithPath:path] 
  NSString *> 



path = [[NSBundle mainBundle] bundlePath];

...根据放置图片的位置。


I'd like to dislay an image in UIWebView using

<img src="imageInBundle.png"/>

The above image is in my bundle. I load it, along with other HTML in a string, like this:

[myWebView loadHTMLString:htmlString baseURL:[NSURL URLWithString: @"http://www.abc.com"]]; 

However, I just get a blue box with a white question mark. Is there something else I need to do?

解决方案

Try to change the

[NSURL URLWithString: @"http://www.abc.com"]

to a

[NSURL fileURLWithPath:path]

where path is something like

NSString *path = [[NSBundle mainBundle] bundlePath];

...depending where the image is placed.

这篇关于在UIWebView中显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆