在选择一个特定单元时禁用所有单元

时间:2017-08-21 09:56:11

标签: ios swift xcode uitableview

我正在创建类似于闹钟应用的东西。像选定日期的警报应用程序。 如果选择了每一天,是否有表的任何方法或委托功能来帮助我禁用所有其他单元格。如果每天都被选中,那么所有其他日子都已经被选中,并且是每天都要通过取消来改变它的唯一方法。

如果有一些简单的方法或lib,请帮忙。否则,我想这需要很长时间,并且每当用户每天选择进行更改时都需要重新加载表。

到目前为止我的代码

 func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    tableView.deselectRow(at: indexPath, animated: true)

    if let cell = tableView.cellForRow(at: indexPath) {

        if cell.accessoryType == .checkmark {
            cell.accessoryType = .none
            if indexPath.row == 0 {
                cell.isUserInteractionEnabled =  true
            }
            removeDays(n: UInt8(indexPath.row))

        } else{
            cell.accessoryType = .checkmark
            if indexPath.row == 0 {
                cell.isUserInteractionEnabled =  false
            }
            addDays(n: UInt8(indexPath.row))
        }
    }
}

0 个答案:

没有答案
相关问题