I have one UITableViewCell. In TableViewCell, I have 7 buttons in single row. I want to play music. When i press button1, its background colour should be changed. If I pressed button2, its background colour should be changed, and button1 would be deselect. I also set the tag for each button in row, but i don't understand, how to do? Sound is playing fine but i am unable to select and deselect buttons. I am using swift3. Thanks in advance.
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> tableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "PlayerCell") as! tableViewCell
cell.Btn_one.addTarget(self, action: #selector(TableViewController.BtnAction_One), for: .touchUpInside)
//For example
if (cell.Btn_one.tag == 1){
cell.Btn_one.backgroundColor = .white
}else if (cell.Btn_two.tag == 2){
cell.Btn_two.backgroundColor = .red
}
}
@IBAction func BtnAction_One(_ sender: UIButton) {
self.play()
}
