我已經創建了一個簡單的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