IOS TableView 去除点击后产生的灰色背景

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"activityTableViewCell";
    activityTableViewCell *cell = (activityTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
         cell = [[activityTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    
    cell.selectionStyle=UITableViewCellSelectionStyleNone;//设置cell点击效果
    
    return cell;
}

  或者

//重写 cell 点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath
{
    //当离开某行时,让某行的选中状态消失
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

  

原文地址:https://www.cnblogs.com/ansyxpf/p/6133481.html