Changing accessoryView in tableview one by one in background
Hi aft开发者_运维问答er I set default icons for cells, I want to change default icons to little screenshots. Screenshots I am becoming from a server one by one and I am creating UIImages from theese. My problem is, that i dont know how to change the accessoryView in concrete cells.
My code from for-cycle is here:
// after I got a bytmap with the screenshot
UIImage *imageCopy = [ImageHelper convertBitmapRGBA8ToUIImage:newBitmap withWidth:width withHeight:height];
UIImageView *imageView = [[UIImageView alloc] initWithImage:imageCopy];
UITableViewCell *myCell = [self.tableView cellForRowAtIndexPath:(NSIndexPath *) i];
myCell.accessoryView = imageView;
[imageView release];
Problem is I think, with line:
UITableViewCell *myCell = [self.tableView cellForRowAtIndexPath:(NSIndexPath *) i];
You have to refresh table after changes:
[self.tableView reloadData]
If it still doesn't change the image there is a probleme in your allocations.
In your case, I would write a subclass of a UITableViewCell
which holds url to your screenshot. Then, as they download you can call UITableView
's metod visibleCells
which returns an array of visible cells. Comparing the url where the image came from and your cell subclasses' url property you can set the proper accesoryView
for the cell.
Problem solved with this line:
UITableViewCell *myCell = [self.tableView cellForRowAtIndexPath: [NSIndexPath indexPathForRow:0 inSection:1] ];
Thanx for user: inovaction
精彩评论