UITableViewControllers会,如果他们的clearsSelectionOnViewWillAppear
属性设置为YES,取消对viewWillAppear中选定行。如果你不使用表格视图控制器与设置(默认是YES,我认为)自己动手:
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
}
落实做了(或会)取消委托方法和解决您的色彩:
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
// do what you want to the cell
}
顺便说一下,其他人SO建议设置该单元格的内容视图(不cell.backgroundColor
,但cell.contentView.backgroundColor
)的颜色,并在willDisplayCell:forRowAtIndexPath:
这样做。
我这样做BU的backgroundColor一些reasons.that是这里的问题 – hacker 2013-03-05 07:07:31