具體的UITableViewCell我有一個tableview中,我想一個imageview的增加它在選擇在該行的單元格的內容查看。addSubview對選擇
這是我當前的代碼,當我點擊任一單元格它只會將imageView添加到最後一行,而不是我點擊的那一行。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
playIcon = [[UIImageView alloc]initWithFrame:CGRectMake(20, 22, 9, 12)];
UIImage *image = [UIImage imageNamed: @"cell_play.png"];
[playIcon setImage:image];
[cell.contentView addSubview:playIcon];
}
你沒有表現cell'如何'聲明/初始化。我會NSLog它,以確保它是有效的...最好使用' - (UITableViewCell *)cellForRowAtIndexPath:(NSIndexPath *)indexPath'。 – smparkes 2012-01-27 21:36:00