【问题标题】:Something wrong when I select UITableViewCell?选择 UITableViewCell 时出现问题?
【发布时间】:2015-05-02 10:50:16
【问题描述】:

当我选择一个 UITableViewCell 时,背景变成灰色,灰色的高度很奇怪。有些单元格很奇怪。我将分隔线样式设置为无。我在前面和脚单元格中添加了标签,所以单元格之间有线条。如第一张图片所示。 其他单元格正常,如第二张图片所示。

【问题讨论】:

  • 2 反对票...你最好提供一些示例代码 sn-ps,比如你如何设置你的单元格,尤其是你选择的背景视图。
  • 你在使用自定义单元格吗?
  • 是的,我天生就有 uitablviewcell。

标签: ios uitableview cell


【解决方案1】:

看来我已经解决了这个问题。 首先设置:

cell.selectionStyle = UITableViewCellSelectionStyleNone;

以及覆盖方法:

- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated
{
    if (highlighted) {
        self.contentView.backgroudColor= [UIColor gray];
    } else {
        self.contentView.backgroudColor= [UIColor white];
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-10
    相关资源
    最近更新 更多