Iphone 是否在UITableViewView中下载异步多个图像?

Iphone 是否在UITableViewView中下载异步多个图像?,iphone,objective-c,cocoa-touch,ipad,asihttprequest,Iphone,Objective C,Cocoa Touch,Ipad,Asihttprequest,如何使用ASIHttpRequest或其他有用的工具在UITableView中下载异步多个映像 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { .......... // Creation UIImageView *avatar; UILabel *content;

如何使用ASIHttpRequest或其他有用的工具在UITableView中下载异步多个映像

 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
 {
      ..........

      // Creation
      UIImageView *avatar;
      UILabel *content; 

      // Tag the IBOutlets
      avatar = (UIImageView*)[cell viewWithTag:14];
      content = (UILabel*)[cell.contentView viewWithTag:4];

      // Field
      avatar.image = image
      content.text = entryReviewtableView.content;
 }

可以使用异步图像视图而不是默认图像视图。作为参考,您可以访问教程

-(void)requestFinished:(ASIHTTPRequest)请求{ [(UIImageView)[[request userInfo]valueForKey:@“imgV”]setImage:[UIImage imageWithData:[request responseData]]

[(UIActivityIndicatorView*) [(UIScrollView*) [scr viewWithTag:([[request username] intValue]+1)] viewWithTag:kActTag] removeFromSuperview];

}

无需为整个框架引入依赖项,例如ASIHTTPRequest,只需下载一个映像即可,使用GCD只需几行简单的代码即可:

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
    NSData *imageDate = [NSData dataWithContentsOfURL:imageURL];
    UIImage *image = [UIImage imageWithData:imageData];
    dispatch_async(dispatch_get_main_queue(), ^{
        avatar.image = image;
    });
});
这是异步的,而且非常好。但只需几行代码,您就可以编写、理解、修复bug、扩展和维护自己

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
    NSData *imageDate = [NSData dataWithContentsOfURL:imageURL];
    UIImage *image = [UIImage imageWithData:imageData];
    dispatch_async(dispatch_get_main_queue(), ^{
        avatar.image = image;
    });
});