开发者

uitableviewcell update

I have uitableview with cells.I download image asynchronous for each cell with ASIHttpRequest and put image into cell when it has been downloaded. Image downloads fine, but it puts when i click on cell, or scroll my uitableview. How to set image AND SHOW it immediatly?

    NSURL *photoURL = [NSURL URLWithString:urlString];
    __block ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:photoURL];
   [request setDownloadCache:[ASIDownloadCache sharedCache]];
   [request setCompletionBlock:^{       
   NSData *responseData = [request responseData];
   cell.imageView.image = [UIImage imageWithData:responseData];
    }];
   [r开发者_JAVA百科equest startAsynchronous];
      //other code (cell.textLabe.text = ...) etc.

Here are screenshots with cell before click on it, and after:

Before:

uitableviewcell update

After:

uitableviewcell update


Try putting [tableView reloadData] inside the completion block.


for updating tableview use

[yourTableView reloadData]

and for download images asynchronously use

http://www.markj.net/iphone-asynchronous-table-image/


First guess, you defined your imageview or calling your image in delegate didSelectedRowAtIndexPath method therefore it appears when you click on cell. Basically to solve your problem,just move your code right in the cellForRowAtIndexPath method.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜