gpt4 book ai didi

iphone - 如何在用户选择 Cell 图像时更改它?

转载 作者:行者123 更新时间:2023-11-28 23:14:36 25 4
gpt4 key购买 nike

在我的自定义单元格子类中,当用户选择一个单元格时,我想更改其上的图像,这是保留的属性。没有 Nib ,一切都是有代码的。

问题:

-首先,即使没有选择任何内容,单元格仍然会出现,上面有新图像。

-其次,当我点击单元格时没有任何变化;

-(void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
UIImage *cry = [UIImage APP_CRYSTAL_SELECTED];
self.leftImage = [[[UIImageView alloc] initWithImage:cry] autorelease] ;
[self.contentView addSubview:self.leftImage];
}

最佳答案

您没有检查它是否在您的代码示例中被选中。

-(void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
if(selected)
{
UIImage *cry = [UIImage APP_CRYSTAL_SELECTED];
self.leftImage = [[[UIImageView alloc] initWithImage:cry] autorelease] ;
[self.contentView addSubview:self.leftImage];
}
else
{
//Remove image here if it exists
}
}

关于iphone - 如何在用户选择 Cell 图像时更改它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6983322/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com