Swift UITableView didSelectRowAtIndexPath not getting called
Everybody is mentioning to set dataSource and delegate of the tableView.But after setting also not working fine then sometimes it may happen because of none or disable selection of table view.
To enable itGo to storyboard -> Select tableView -> click on the attribute inspector ->go to selector -> Select selection as single selection (or multiple selection according to the requirements.)
Please find attached screenshot for your suitability.
You have to set an @IBOutlet
to the tableView
in you ViewController
and set as it's delegate
and dataSource
to you can see the data an respond to changes in the tableView
.
Something like this :
override func viewDidLoad() { super.viewDidLoad() self.tableView.delegate = self self.tableView.dataSource = self}
And implements the UITableViewDataSource
protocol too.
Or you can too in the Interface Builder set the ViewController
as it's delegate and dataSource
(more easy to do I think) and avoid to set manually in code like above. Is up to you.
I hope this help you.