如何在uiwebview中显示图像 [英] How to display images in the uiwebview

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

问题描述

我正在实现一个UIWebView。在那我只需要显示一个iamges。但我无法做到。请查看我的代码,如果我有任何错误,请告诉我。

I am implementing a UIWebView. In that I just need to display an iamges. But I am not able to do it. Please check out my code, and please let me know does I make any mistake.

NSString *absStirng=[[[NSBundle mainBundle] resourceURL] absoluteString];
 appendString =[appendString stringByAppendingString:@"<html>"];
 appendString =[appendString stringByAppendingString:@"<body>"];
 appendString =[appendString stringByAppendingString:@"<a href='/#/'><img src="];
 appendString =[appendString stringByAppendingString:absStirng];
 appendString =[appendString stringByAppendingString:@"image.png /></a>"];
 appendString =[appendString stringByAppendingString:@"</body>"];
 appendString =[appendString stringByAppendingString:@"</html>"];
 [myWebView loadHTMLString:appendString baseURL:[NSURL URLWithString:@"http://serverUrl/"]; 

请帮我解决这个问题,我试试两天..
谢谢你,
Madan Mohan。

Please help me out of this, I am trying it from two days.. Thank you, Madan Mohan.

推荐答案

你是从returnString而不是appendString加载的。如果absStirng是你的图片网址,则无需另外添加image.png。我认为你应该在创建html时将图像url放在引号中。

You are loading from "returnString", instead of "appendString". If absStirng is your image url, no need to put image.png in addition. And I think you should put the image url in quotes when creating the html.

使用可变字符串也可以获益。

You would also benefit by using a mutable string.

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

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