2010-09-10 4 views
2

J'ai créé un lecteur RSS qui reçoit un flux de blogspot. Le texte de l'histoire, le titre, etc. fonctionne bien. Mais les images affichées dans le flux s'affichent sous la forme de liens au lieu d'une image. Comment puis-je afficher les images?iPhone SDK - Problème d'analyse XML à partir du flux RSS

+0

pouvez-vous poster l'exemple xml ou donner un lien vers le fichier xml? – Saurabh

Répondre

1

Voici un code que j'utilise pour télécharger dynamiquement des images dans une liste:

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

Hope it helps, bonne chance!

Questions connexes