Use closure
inside your custom UITableViewCell
to handle this scenario.
In your custom UITableViewCell
create a handler
and call it when the button
is tapped inside the cell
, i.e.
class CustomCell: UITableViewCell {
var handler: (()->())?
@IBAction func onTapButton(_ sender: UIButton) {
handler?()
}
}
Now, set the handler
in cellForRowAt
when creating the cell
, i.e.
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! CustomCell
cell.handler = {
//present your controller here...
}
return cell
}