当我点击它时,我正在尝试更改我的单元格图像。我使用如下代码:
cell.backgroundView = [[[UIImageView alloc] init] autorelease];
cell.selectedBackgroundView = [[[UIImageView alloc] init] autorelease];
cell.textLabel.textColor = [UIColor colorWithRed:162.0/255.0 green:13.0/255.0 blue:20.0/255.0 alpha:1.0];
cell.textLabel.text = [channelCategories objectAtIndex:indexPath.row];
UIImage * backgroundImage = [UIImage imageNamed:@"topAndBottomRow.png"];
UIImage * selectionBackground = [UIImage imageNamed:@"topAndBottomRowSelected.png"];
cell.backgroundColor = [UIColor clearColor];
UIImage *indicatorImage = [UIImage imageNamed:@"indicator.png"];
cell.accessoryView = [[[UIImageView alloc] initWithImage:indicatorImage] autorelease];
cell.backgroundColor = [UIColor clearColor];
((UIImageView *)cell.backgroundView).backgroundColor = [UIColor clearColor];
((UIImageView *)cell.backgroundView).autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
((UIImageView *)cell.backgroundView).image = backgroundImage;
((UIImageView *)cell.selectedBackgroundView).image = selectionBackground;
任何人都可以帮我解决这个问题吗? 谢谢。
答案 0 :(得分:0)
不要对UIImageView
进行类型转换。分配另一个UIImageView
对象,设置其图片,然后将UIImageView
分配给cell.backgroundView
或cell.selectedBackgroundView