I made a tableview controller, and added a button inside of the prototype cell. I then made a new swift file for this cell in which I dragged this button.
Next, i made a new tableview file, and added the images which should be shown inside the button. So far so good.
The problem is this: i wanted to perform a segue from each of the buttons, which all have their own view controller (this was easier than using a master and detail view controller, since they're all really different). My problem is the following: I expected this to work just fine, using this code:
cell.sportButton.tag = indexPath.row
cell.sportButton.addTarget(self, action: #selector(TableViewControllerSport.buttonClicked), forControlEvents: .TouchUpInside)
The func buttonClicked:
func buttonClicked(sender: UIButton)
{
let buttonRow = sender.tag
if buttonRow == 0 {
self.performSegueWithIdentifier("segueSportinfrastructuur", sender: self)
}
else if buttonRow == 1 {
self.performSegueWithIdentifier("segueSportdienst", sender: self)
}
else if buttonRow == 2 {
self.performSegueWithIdentifier("segueSportraad", sender: self)
}
else if buttonRow == 3 {
self.performSegueWithIdentifier("segueSportverenigingen", sender: self)
}
else if buttonRow == 4 {
self.performSegueWithIdentifier("segueGsport", sender: self)
}
else if buttonRow == 5 {
self.performSegueWithIdentifier("segueSportactiviteiten", sender: self)
}
}
Which references to the different segues. The problem is: when I click one of the buttons, it will always perform the "segueSportinfrastructuur" first, and after that the segue it should perform. So when I click the back button, the app goes back to the "Sportinfrastructuur" VC, so I have to click the back button again to go back to the tableView.
Anyone who knows how to fix this, it would be much appreciated!