カスタム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を呼び出すと、完全に停止します)(テーブルビューをスクロールして更新できます)