我有一个自定义的UITableViewCell和一个自定义的背景图片。如何在选择时更改该图像?
发布于 2011-10-17 19:31:45
您知道它是哪个单元格,因为您有一个索引路径。你知道细胞有一些图像视图,上面有你的图像。所以你唯一要做的就是找到那个单元格,把图像改成你想要的,然后更新表视图。
如下所示:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
CustomCell *cell = (CustomCell*)[self tableView:tableView cellForRowAtIndexPath:indexPath];
cell.myCustomImageView.image = myNewImage.
[myTableView reloadData];
}发布于 2011-10-17 19:37:56
尝试为UITableViewCell设置selectedBackgroundView。
发布于 2011-10-17 19:33:40
您可以使用(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath,只需在其中更改您的图像。
https://stackoverflow.com/questions/7793066
复制相似问题