在使用UITableViewCell的时候,我们需要在点击的时候出现背景色或者不想使用这个cell的点击功能,这个时候,我们只要设置如下的几个参数就好,
cell.selectionStyle = UITableViewCellSelectionStyleNone; //无法点击
cell.selectionStyle = UITableViewCellSelectionStyleBlue;
//点击是蓝色
cell.selectionStyle = UITableViewCellSelectionStyleGray; //点击是灰色
//设置选中Cell的响应事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[tableView deselectRowAtIndexPath:indexPath animated:YES];//选中后的反显颜色即刻消失
}
这样我们在点击cell之后,会显示一下颜色,然后颜色消失,