0

我在其内容视图中UITableViewCell有一个自定义。UIButton当我点击单元格以选择它时,按钮的背景图像也会切换到其突出显示状态。我尝试通过-setSelected:animated:在单元格中实现来防止它,如下所示:

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    [[self exampleButton] setSelected:NO];
}

没有这样的运气;该按钮仍会更改其样式。有任何想法吗?

4

2 回答 2

0

使用exampleButton.adjustsImageWhenHighlighted = NO.

于 2012-08-13T03:16:06.533 回答
0

我认为您应该更改未选中的突出显示状态。

- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated
{
    [super setHighlighted:highlighted animated:animated];
    _exampleButton.highlighted = NO;
}

- (void)setSelected:(BOOL)highlighted animated:(BOOL)animated
{
    [super setSelected:highlighted animated:animated];
    _exampleButton.highlighted = NO;
}
于 2014-03-10T11:49:40.030 回答