iPhone SDK-从RSS源解析XML时出现问题
我制作了一个RSS阅读器,可以从blogspot获取提要。 故事、标题等的文本效果良好。 但是在feed中发布的图片显示为链接而不是图片。iPhone SDK-从RSS源解析XML时出现问题,iphone,xml,parsing,rss,Iphone,Xml,Parsing,Rss,我制作了一个RSS阅读器,可以从blogspot获取提要。 故事、标题等的文本效果良好。 但是在feed中发布的图片显示为链接而不是图片。 如何显示图像?以下是一些用于将图像动态下载到列表中的代码: //starts the downloading of the image - (void) downloadImage { [NSThread detachNewThreadSelector:@selector(imageDownloadWorker:)
如何显示图像?以下是一些用于将图像动态下载到列表中的代码:
//starts the downloading of the image
- (void) downloadImage
{
[NSThread detachNewThreadSelector:@selector(imageDownloadWorker:)
toTarget:self
withObject:[self getAvatarUrl]/*here goes your url*/];
}
//does something with the image once loaded
- (void)imageLoaded:(UIImage *)image
{
//do something
}
//downloads the image
- (void)imageDownloadWorker:(NSString *)urlString
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSURL *url = [NSURL URLWithString:urlString];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *image = [[UIImage alloc] initWithData:data];
[self performSelectorOnMainThread:@selector(imageLoaded:)
withObject:[image autorelease]
waitUntilDone:YES];
[pool drain];
}
希望有帮助,祝你好运 您可以发布示例xml或提供指向xml文件的链接吗?