在表视图的列表项实现选择打勾的效果(多选)

2017-01-03  本文已影响15人  yytester

需要实现的方法:

    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath){
        
        print("You selected cell #\(indexPath.row)!")
       
        let cell = tableView.cellForRow(at: indexPath)

       // 当前已是勾选状态则取消勾选  
        if cell?.accessoryType == .checkmark {     
            cell?.accessoryType = .none   
        } else {
            cell?.accessoryType = .checkmark
            addTips()
        }
     
    }

单选可以参考:这里

上一篇 下一篇

猜你喜欢

热点阅读