Burak Üstün

Table Button Action

You need to add target for that button.

myButton.addTarget(self, action: "connected:", forControlEvents: .TouchUpInside)

And of course you need to set tag of that button since you are using it.

myButton.tag = indexPath.row

You can achieve this by subclassing UITableViewCell. Use it in interface builder, drop a button on that cell, connect it via outlet and there you go. ** **EDIT: To get the tag in the connected function:

func connected(sender: UIButton){
    let buttonTag = sender.tag
}

EDIT2:This answer was provided for swift 1.2, as suggested in comments, syntax is a little different for swift 2.2.

myButton.addTarget(self, action: #selector(ClassName.FunctionName(_:), forControlEvents: .TouchUpInside)

EDIT3: Updated for Swift 3

myButton.addTarget(self, action: #selector(ClassName.FunctionName.buttonTapped), for: .touchUpInside)

Çalışan Örnek

cell.btnTodo.addTarget(self, action: #selector(deleteItem(sender:)), for: .touchUpInside)

//deleteItem -> Fonksiyon Adı

#swift

February 15, 2017