请教高手:有关UITextView 无法显示本地图片的问题

andy_123 2015-10-08 08:31:02
使用UITextView 加载html,html中有img标签,
<img src="http://www.sina.com.cn/1.jpg"> 这样的html代码中的图片可以正常显示
如果使用本地图片就不行,比如:
/var/mobile/Applications/F059DC2B-C3AE-494D-BD22-21E2147DCE15/Library/Caches/1.jpg
请问是什么原因?有解决办法吗?测试代码如下: 图片无法显示


textView = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];
NSString *textString = @"<?xml version=1.0 encoding=UTF-8 standalone=no?><html xmlns=http://www.w3.org/1999/xhtml><head><title></title></head><body><p>test html image display<img alt=cover src=/var/mobile/Applications/F059DC2B-C3AE-494D-BD22-21E2147DCE15/Library/Caches/001.jpeg></img></p></body></html>";
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithData:[textString dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
textView.attributedText =attributedString;
[self.view addSubview:textView];
...全文
135 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
andy_123 2015-10-09
  • 打赏
  • 举报
回复
引用 2 楼 jiuqiyuliang 的回复:
你确定自己的路径写对了吗?
路径没有错,检查过了
程序猿小亮 2015-10-09
  • 打赏
  • 举报
回复
你确定自己的路径写对了吗?
andy_123 2015-10-09
  • 打赏
  • 举报
回复
一个回答都没有,晕了

29,027

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧