如何在点击iphone中的单元格时更改单元格背景图片????我试过以下但是它无法正常工作....
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectMake(0,0,320,50) reuseIdentifier:myid] autorelease];
cell.selectedBackgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"myImage.png"]];
}
答案 0 :(得分:2)
cell.selectedBackgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"myImage.png"]];
在上面的代码中你忘了自动释放;还有你设置tableview的委托吗?在tableview:didselectRowAtIndexpath
方法上设置断点以检查它是否被调用。
顺便说一句,你的代码似乎是正确的。
答案 1 :(得分:0)
您可以更改UITableView的selectionType
使用
cell.setSelectionStyle = [UITableViewSelectionStyleGray/Blue/None] (only 3 types)
上面代码中的一些syntex错误尝试使用正确的syntex
默认情况下会是蓝色......
答案 2 :(得分:0)
cell.selectedBackgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@“mImage.png”]]