UITableView和ASIHTTPRequest

时间:2011-08-24 08:03:00

标签: uitableview asihttprequest

如何将下载的图像放入单元格?

我不知道在加载到cell.imageView.image时如何将响应数据输出。

以下是代码:

   - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
   ....
   ....
   NSURL *photoURL = [NSURL URLWithString:user.photo];
   ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:photoURL];
   [request setDownloadCache:[ASIDownloadCache sharedCache]];
   [request setDelegate:self];
   [request startAsynchronous];
   cell.textLabel.text = [NSString stringWithFormat:@"%@ %@",user.first_name,user.last_name];
   cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

   //image loaded
   - (void)requestFinished:(ASIHTTPRequest *)request
   {
      NSData *responseData = [request responseData];
   }

1 个答案:

答案 0 :(得分:2)

Here是一个示例代码,其中包含指南和a brief description.