Reputation: 725
I am trying to select a predefined cell on my tableView. On viewDidLoad() I added this code
tableView.selectRow(at: selectionIndexPath, animated: true, scrollPosition: .none)
This dose work only if I set self.tableView.allowsMultipleSelection to true. Otherwise the cell is not being selected. Do you have an idea about the problem. I also did self.tableView.allowsSelection = true
and still have the problem.
Upvotes: 0
Views: 53
Reputation: 2874
Move your code to viewDidAppear:
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
tableView.selectRow(at: selectionIndexPath, animated: true, scrollPosition: .none)
}
Upvotes: 2