How to detect one button in tableview cell

后端 未结 4 673
说谎
说谎 2020-11-28 16:14

How to detect one button in UITableviewCell, I have 10 UIButton in UITableViewCell, next when I click on UIButton then i

4条回答
  •  孤城傲影
    2020-11-28 16:53

    In your cellForRowAt method, do add tag number to the buttons

    cell.bookMarkBtn.tag = indexPath.row;
    

    Then

    @IBAction func bookMarkBtnAction(_ sender: UIButton) {
    
        sender.isSelected = !sender.isSelected
    
        if(sender.tag == 0)
        {
            ...
        } else if (sender.tag == 1)
        {
            ...
        }
    }
    

提交回复
热议问题