我已经创建了一个简单的XML解析器来解析我的rss源到我的应用程序。 id,currentstatus,从xml文件中解析简单的图片。 但我无法从XML文件中获取图像。 。我从xml文件中检索所有图像。但noimage.jpg不显示。你可以请任何帮助我。如何在IOS中打印xml图像?
XML代码
<Agent>
<id>3422</id>
<currentstatus>Logged Off</currentstatus>
<picture>1</picture>
</Agent>
<Agent>
<id>3432</id>
<currentstatus>Logged Off</currentstatus>
<picture>0</picture>
</Agent>
我尝试下面的代码:
UIImage * cellimages = [[UIImage alloc]init];
NSString *string1 = @"http://telecomstats.co.uk/images/LLReaderProfile/";
NSString *cellvalue =[[[[self rssParser]rssItems]objectAtIndex:indexPath.row]picture];
NSString* disable = [[NSString alloc] initWithString:@"0"];
if (cellvalue == disable)
{
cellimages = [UIImage imageWithContentsOfFile:@"http://telecomstats.co.uk/images/LLReaderProfile/noimage.jpg"];
}
else {
cellimages = [string1 stringByAppendingString:[[[[self rssParser]rssItems]objectAtIndex:indexPath.row]id]];
cellimages = [cellimages stringByAppendingString: @".jpg"];
}
cellimages = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:cellimages]]];
cell.imageView.image = cellimages;
是否有人能帮助我吗? 感谢您的帮助和见解。
URL是否正确?至少noimage网址提供了一个未找到的域名。 –
感谢您的重播抱歉,我输入了错误的URL正确的URL是:static.telecomstats.co.uk/images/psychic/LLReaderProfile/...我尝试了以下方法以及cellimages = [string1 stringByAppendingString:@“noimage.jpg” ]。但没有用 – Livelines