【问题标题】:How do I remove UITableViewCell action on finger tap?如何删除手指点击时的 UITableViewCell 操作?
【发布时间】:2011-12-29 00:19:02
【问题描述】:

我刚刚创建了 UITableViewCell。我添加了两个按钮。然后我为单元格设置透明背景。

cell.backgroundView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];

但是有一个问题。当用户点击单元格时,它会将颜色更改为蓝色。但我不想在用户点击时看到任何反应。

请看截图。

点击操作

【问题讨论】:

标签: ios uitableview


【解决方案1】:

Swift 5 更新:

将选择样式设置为none

    cell.selectionStyle = .none;

不要使用 - cell.isUserInteractionEnabled = false 否则您的按钮将不起作用。

【讨论】:

    【解决方案2】:

    有几种方法:

    1.cell.userInteractionEnabled = NO;(使单元格“准备就绪” - 这包括按钮)

    2.cell.selectionStyle = UITableViewCellSelectionStyleNone;(禁用仅突出显示)

    3.tableView.allowsSelection = NO;(禁用仅突出显示整个表格)

    4.tableView.UserInteractionEnabled:NO;(使整个表格“准备就绪” - 包括按钮)

    【讨论】:

    • 如果他将 cell.userInteractionEnabled 设置为 no,按钮将不起作用。与 tableView.allowselection 相同
    • 我已经添加了所有的描述。
    【解决方案3】:

    cell.selectionStyle = UITableViewCellSelectionStyleNone;

    【讨论】:

      【解决方案4】:

      Swift 4解决方案:

      // disable selection for a specific cell
      cell.selectionStyle = .none
      
      // disable selection for all cells inside your TableView
      tableView.allowsSelection = false
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-03-26
        • 2019-09-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-06-07
        相关资源
        最近更新 更多