ios - UITableViewCell 内的 UIImageViews 不会被选中

标签 ios uitableview uiimageview

我正在使用此图像上表示的自定义 UITableViewCells 创建表:

enter image description here

在单元格的左侧,有一个灰色的 UIImageView、三个标签和一个带有线条的 UIImageView。单元格可以根据其内容具有不同的高度。如果我插入一张图片作为背景,这张图片将被拉伸(stretch)。所以我创建了两个 UIImageViews:顶部(从单元格的顶部到第一个半圆的底部)和底部(从最后一个半圆的底部到单元格的底部)和带有图案图像背景颜色的 UIView。重复此 View 中的图案图像以完全填充 UIView。我还计算了单元格的高度,以便 UIView 正确加入底部 UIImageView。

我的问题是:当单元格被选中时,我的 imageViews 没有被选中。只有中间的 UIView 被选中。您可以在下面的图片中看到这一点:
enter image description here

enter image description here

我希望所有的 imageViews(top, bottom ad gray) 都被单元格选中。我怎样才能做到这一点?

最佳答案

您必须覆盖 UITableViewCell 子类中的方法。

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    self.imageView.image = [UImage imageNamed:@"some_other_image.png"];
}

关于ios - UITableViewCell 内的 UIImageViews 不会被选中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18062067/

相关文章:

objective-c - UIView ContentMode 单元格图像的缩放模式在单元格被触摸(突出显示)后静默变化

ios - 如何创建 Airbnb iOS App Explore 选项卡?

ios - 从 JSON 写入/读取图像以在 Xcode 中使用

ios - 禁用 tabBar 上的用户交互

ios - PDFKit iOS 11 : How to change the line width of Ink annotation?

iphone - tableview 中的字体大小变化是否可以重新使用?

ios - 仅刷新 UITableView 中的自定义标题 View ?

ios - Assets 目录未在项目中使用

iphone - NSFetchedResultsController 错误 : 'NSInternalInconsistencyException' , 原因: 'no object at index 1 in section at index 0'

ios - 如何在 IOS 相机中启用稳定和 HDR?