How to detect one button in UITableviewCell, I have 10 UIButton in UITableViewCell, next when I click on UIButton then i
Use button tag for this.
In tableViewController
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "HomeTableViewCell", for: indexPath) as! HomeTableViewCell
cell.bookMarkBtn.tag = indexPath.row
cell.bookMarkBtn.addTarget(self, action: #selector(self. bookMarkBtnAction), for: .touchUpInside)
return cell
}
@objc func bookMarkBtnAction(sender: UIButton) {
if sender.tag == 0 { //or which indexpath do you want.
//code
} else if sender.tag == 1 {
//code
}
..
}
remove @IBAction func bookMarkBtnAction(_ sender: UIButton) from tableviewcell class