我制作了一个自定义 UITableViewCell:
SListViewCell * cell = nil;
// cell = [listView dequeueReusableCellWithIdentifier:CELL];
if (!cell) {
cell = [[[SListViewCell alloc] initWithReuseIdentifier:CELL] autorelease];
}
listView.separatorColor = [UIColor clearColor];
cell.backgroundColor = [UIColor clearColor];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
UIButton* btn = [UIButton buttonWithType:UIButtonTypeCustom];
btn.tag = index;
[btn setFrame:CGRectMake(0, 0, 42, 42)];
//setBtnImage will download image from network. when the UIButton click it is will change button image
[self setBtnImage:index btn:btn];
[btn addTarget:self action:@selector(typeTapped:) forControlEvents:UIControlEventTouchUpInside];
[cell addSubview:btn];
return cell;
typeTapped 方法:
-(void)typeTapped:(id)sender
{
UIButton* btn = (UIButton)sender;
//download image from network in ohter thread and change button' image.
NSThread * thread = [Thread alloc] initWith:@selecter(downloadImage:)....
[thread start];
[thread release];
}
//download image
-(void)downloadImage:(UIButton*)btn....
{
//download
UIImage* image= ....
//UITableView is not update
//it is will update when i scroll tableview.
[btn setImage:image ......];
}
那么我如何在其他线程中更新 UITableViewCell 。(如果我调用 reloadDate 它将完全停止)(我可以滚动 tableview 来更新它)