Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/116.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 在Swift中禁用未启用UserInteractionEnabled的单元格选择_Ios_Swift - Fatal编程技术网

Ios 在Swift中禁用未启用UserInteractionEnabled的单元格选择

Ios 在Swift中禁用未启用UserInteractionEnabled的单元格选择,ios,swift,Ios,Swift,我有一个带按钮的单元格,将UserInteractionEnabled设置为false也会禁用按钮。现在,如果我使用cell.selectionStyle=UITableViewCellSelectionStyle.None。虽然单元格没有高亮显示,但我松开了上一个选定的单元格。有什么方法可以克服这个问题吗?实现UITableView委托方法 tableView(_ tableView: UITableView, willSelectRowAtIndexPath indexPath: NSInd

我有一个带按钮的单元格,将
UserInteractionEnabled
设置为false也会禁用按钮。现在,如果我使用
cell.selectionStyle=UITableViewCellSelectionStyle.None
。虽然单元格没有高亮显示,但我松开了上一个选定的单元格。有什么方法可以克服这个问题吗?

实现
UITableView
委托方法

tableView(_ tableView: UITableView, willSelectRowAtIndexPath indexPath: NSIndexPath) -> NSIndexPath?

对于不希望被选择的行,返回
nil

。。。对于Swift 3,委托方法为:

    public func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? {
    if indexPath.row == 0 {
        return nil
    } else {
        return indexPath
    }
}

你想选择多个单元格吗?不是一个。但不是更新代码中带有按钮的单元格。仍然丢失所选行您的意思是indexPath.row==0哦,糟糕。谢谢!