gpt4 book ai didi

iPhone SDK - 从 RSS feed 解析 XML 时出现问题

转载 作者:行者123 更新时间:2023-12-03 21:22:09 25 4
gpt4 key购买 nike

我制作了一个 RSS 阅读器,可以从 blogspot 获取提要。故事、标题等文字效果很好。但提要中发布的图像显示为链接而不是图像。如何显示图像?

最佳答案

这是我用来动态下载图像到列表中的一些代码:

//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];
}

希望对你有帮助,祝你好运!

关于iPhone SDK - 从 RSS feed 解析 XML 时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3686686/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com