2012-03-01 56 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”。
它也适用于苹果的例子。