I am using an UITableViewController for it and I override the following method and try to enable different segues when the user select different row.
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
print("You selected row #\(indexPath.row)!")
switch indexPath.row {
case 3:
performSegue(withIdentifier: "segue3", sender: self)
case 8:
performSegue(withIdentifier: "segue8", sender: self)
default:
break
}
}
But actually, this method never get called, and the print out never show up when I select a row.
I did enable single selection, enable user interaction and set the delegate and datasource to the controller itself (That's automatically set when using UITableViewController, right?)
I am using static cells and default UITableViewCell. The view controller is UITableViewController.

Update:
I try to replace:
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: IndexPath)
With:
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
And this doesn't work also.
for Swift 3
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath){
// your code ...
}
and one thing make sure your tableView single selection property is selected ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With