Create custom cell
Write below code inside cellForRowAt indexPath
of UItableview Method
cell.buttonname?.addTarget(self, action: #selector(self.buttonmethod), for: .touchUpInside)
cell.buttonname.tag = indexPath.section
// Button Clicked Method
func buttonmethod(_ button: UIButton) {
print(button.tag)
// perform some action
}