2012-10-10 48 views
-3

我想再次詢問關於來自json的uiimage。這裏是我的JSON來自JSon的UIImage

- image { 
     original: "http://someurl/B777_Tail.jpg", 
     thumbnail: "http://someurl/thumbnail/B777_Tail.jpg" 
    }, 

不,我已經嘗試用這種方法來獲得該上的UITableViewCell

NSString *path=[[[json objectAtIndex:indexPath.row] objectForKey:@"image"]objectForKey:@"thumbnail"]; 
    NSLog(@"%@",path); 


    UIImage *theImage = [UIImage imageWithContentsOfFile:path]; 
    cell.imageView.image = theImage; 

是我的代碼中的任何錯誤?因爲它不在UItableviewCell上顯示;

+0

呃...你有一些網址。 'imageWithContentsOfFile'將從文件加載...。你可以嘗試使用AsyncImageView。在gitHub上搜索它。 – George

回答

2

起初您是以錯誤的方式加載圖片。最簡單的加載代碼將如

NSData* imageData = [NSData dataWithContentsOfURL: [NSURL URLWithString: path]]; 
UIImage* image = [UIImage imageWithData: imageData]; 

如果您的路徑被正確提取,您將看到圖像。