I am working on a project on which I have to preselect a particular cell.
I can preselect a cell using -willDisplayCell, but I can\'t deselect it when t
Swift 3.0:
Following the protocol conformance section of the ray wenderlich swift style guide, to keep related methods grouped together, put this extension below your view controller class like that:
// your view controller
class MyViewcontroller: UIViewController {
// class stuff here
}
// MARK: - UITableViewDelegate
extension MyViewcontroller: UITableViewDelegate {
// use the UITableViewDelegate method tableView(_:didSelectRowAt:)
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
// your code when user select row at indexPath
// at the end use deselectRow
tableView.deselectRow(at: indexPath, animated: true)
}
}