选择UITableViewCell时禁用选择效果

时间:2011-01-14 05:23:57

标签: iphone objective-c ios xcode cocoa-touch

如何在选择特定UITableViewCell

时禁用选择效果

7 个答案:

答案 0 :(得分:21)

tableView:cellForRowAtIndexPath:方法

中的

使用此

cell.selectionStyle = UITableViewCellSelectionStyleNone

答案 1 :(得分:3)

Swift 3.0

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "CellIdentifier", for: indexPath) as! UITableViewCell
    cell.selectionStyle = .none
    return cell
  }

通过设置:

完成工作

cell.selectionStyle = .none

答案 2 :(得分:2)

有一个委托方法将setselectionstyle设置为none。一旦设置了这个,重新加载表会产生所需的效果。

答案 3 :(得分:2)

你可以使用:

cell.selectionStyle = UITableViewCellSelectionStyleNone;

答案 4 :(得分:0)

您可以使用cell.selectionStyle = UITableViewCellSelectionStyleNone;

[cell setSelectionStyle:UITableViewCellSelectionStyleNone];

cellForRowAtIndexPath dataSource method

中的

答案 5 :(得分:0)

didSelectRowAtIndexPath:index方法

写下来

cell.selectionStyle = UITableViewCellSelectionStyleNone

OR

[self.tblName deselectRowAtIndexPath:indexPath animated:NO];

答案 6 :(得分:0)

在Swift 4.5 / 5.0中

cell.selectionStyle = UITableViewCell.SelectionStyle.none

或者,

cell.selectionStyle = .none
相关问题