which cell button has pressed in tableView in swift 3

前端 未结 2 1637
悲哀的现实
悲哀的现实 2021-02-11 08:20

I have read similar questions like this but these codes didn\'t worked for me so please help : I have a table view with some buttons in each cells - This table view is factor fo

2条回答
  •  -上瘾入骨i
    2021-02-11 08:59

      Here is update
    
    just leave it, i explained it more simple,
    create a button action in your cell class,then
    Writre the code:-
    
    > //Cell class
    
    protocol CellDelegate: class {
        func didTapCell(index: IndexPath)
    }
      var delegateCell:CellDelegate?
      var indexPath:IndexPath?
     @IBAction func buttonCellClick(_ sender: Any) {
            delegateCell?.didTapCell(index: indexPath!)
        }
    
    > //In ViewController
    
     cell.delegateCell = self
     cell.indexPath = indexPath
    
     func didTapCell(index: IndexPath) {
            print("PRESS BUTTON >> \(index.row)")
        }
    

提交回复
热议问题