cellForRowAt
,您可以为里面的按钮将操作委托给vc
let arr = [false,true,false,false,false] first index is dummy as it will be skipped in Create New HashTag
//
@objc func btnClicked(_ sender:UIButton) {
arr[sender.tag] = !arr[sender.tag]
}
//
内部
cellForRowAt公司
if (indexPath == [0,0]) {
let image = UIImage(named: "add")
cell.checkBoxOutlet.setBackgroundImage(image!, for: .normal)
cell.pickerLabel.text = "Create New HashTag"
cell.isCreateTagCell = true
}else{
let image = UIImage(named: arr[indexPath.row] ? "tick" : "uncheck")
cell.checkBoxOutlet.setBackgroundImage(image!, for: .normal)
cell.pickerLabel.text = arrayHashTags[indexPath.row]
cell.isCreateTagCell = false
}
cell.button.addTarget(self, action: #selector(btnClicked(_:)), for: .touchUpInside)
cell.button.tag = indexPath.row