简体   繁体   English

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

[英]Changing selection image with custom table cell

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

You know which cell it is because you have an indexpath. 你知道它是哪个单元格,因为你有一个索引路径。 You know that cell has some imageview with your image on it. 您知道单元格上有图像的图像视图。 So the only thing you have to do is find that cell change the image to the one you want and update the tableview. 因此,您唯一需要做的就是找到单元格将图像更改为您想要的图像并更新tableview。

Something like this: 像这样的东西:

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

    cell.myCustomImageView.image = myNewImage.

    [myTableView reloadData];
}

尝试为UITableViewCell设置selectedBackgroundView。

你可以使用(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath ,只需更改你的图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM