如何使tableView 单元格的某些按钮可点击而某些不可点击| IOS

问题描述

我有一个 tableView,其中每个单元格都包含一个具有不同标题的按钮。

enter image description here

实际上我正在将一个 titles 数组传递给按钮。
cell.applyButton.setTitle(titleValues[indexPath.row],for: .normal)

现在我只想让那些具有标题时间表的按钮可点击。请帮忙。

解决方法

根据标题设置按钮的 .isEnabled 属性:

cell.applyButton.setTitle(titleValues[indexPath.row],for: .normal)
cell.applyButton.isEnabled = titleValues[indexPath.row] == "Schedule"