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