2012-03-01 55 views
0

我有一個數組,其中有一個內容圖像的URL「Image」。我想在我的表格視圖中顯示該圖像。 如何做。請給我建議。解析Iphone中的圖像問題

+0

放置活動指示器直到它下載加載 – 2012-03-01 05:15:14

+0

UItablView和NSMutableArray,NSMusicDirectory也從Apple文檔讀取「https://github.com/rs/SDWebImage」 – 2012-03-01 05:18:47

+0

看看這個鏈接..... panagtakdo.com/文件/ MyAsynchronousImageLoader/MyAsynchronousImageLoader.zip – Narayana 2012-03-01 05:20:21

回答

0
img_view = [[UIImageView alloc]init]; 
    img_view.autoresizingMask = UIViewAutoresizingFlexibleWidth; 
    img_view.frame = CGRectMake(0,0,130, 75); 
    activityIndicator = [[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge] autorelease]; 

    [img_view addSubview: activityIndicator]; 
    activityIndicator.center = CGPointMake(50,30); 

    NSOperationQueue *queue = [NSOperationQueue new]; 
    NSInvocationOperation *operation = [[NSInvocationOperation alloc] 
             initWithTarget:self 
             selector:@selector(loadImage:) 
             object:[[xmlParser data1] objectAtIndex:indexPath.row]];     
    [queue addOperation:operation]; 
    [operation release]; 
    [cell.contentView addSubview:img_view]; 


-(void)loadImage:(Book *)book 
{ 
[activityIndicator startAnimating]; 

NSString *imgurl=[book image_url]; 
NSURL *url=[[NSURL alloc]initWithString:imgurl];  

NSData *img=[[NSData alloc]initWithContentsOfURL:url]; 
UIImage *image=[UIImage imageWithData:img]; 

img_view.image=image; 

[activityIndicator stopAnimating]; 
} 
+0

如果你想要更多的幫助請求 – 2012-03-01 05:18:18

+0

你能給我發送樣本代碼嗎? – 2012-03-01 23:19:38

+0

這是更多的示例代碼 – 2012-03-02 04:11:35

1

您可以在谷歌搜索使用「懶加載圖像的tableview」。
它也適用於蘋果的例子。