使用自定义表格单元格更改选择图像

时间:2011-10-17 11:26:34

标签: iphone objective-c ios uitableview

我有一个带有自定义背景图像的自定义UITableViewCell ..如何在选择时更改该图像?

3 个答案:

答案 0 :(得分:3)

你知道它是哪个单元格,因为你有一个索引路径。 您知道单元格上有图像的图像视图。 因此,您唯一需要做的就是找到单元格将图像更改为您想要的图像并更新tableview。

这样的事情:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath  *)indexPath
{
    CustomCell *cell = (CustomCell*)[self tableView:tableView cellForRowAtIndexPath:indexPath];

    cell.myCustomImageView.image = myNewImage.

    [myTableView reloadData];
}

答案 1 :(得分:1)

尝试为UITableViewCell设置selectedBackgroundView。

答案 2 :(得分:0)

您可以使用(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath,只需更改内部图片。