繁体   English   中英

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

[英]Changing selection image with custom table cell

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

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

像这样的东西:

- (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