2
我做了一个RSS阅读器,从blogspot获取一个feed。 从故事,标题等文本工作正常。 但是,Feed中显示的图像显示为链接而不是图像。 如何显示图像?iPhone SDK - 问题从RSS源解析XML
我做了一个RSS阅读器,从blogspot获取一个feed。 从故事,标题等文本工作正常。 但是,Feed中显示的图像显示为链接而不是图像。 如何显示图像?iPhone SDK - 问题从RSS源解析XML
下面是一些代码,我用动态图像下载到一个列表:
//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文件? – Saurabh 2010-09-10 17:14:52