0

I want to set the default selected row by selectRow(at:animated:scrollPosition:). But the document said calling this method does not cause the delegate to receive a tableView(_:didSelectRowAt:) message.

How to set the default selected row and call the tableView(_:didSelectRowAt:)?

NSNoob
  • 5,548
  • 6
  • 41
  • 54
jybsuper
  • 179
  • 2
  • 10

3 Answers3

1

I just have to call the tableView(_:didSelectRowAt:) programmatically

NSNoob
  • 5,548
  • 6
  • 41
  • 54
jybsuper
  • 179
  • 2
  • 10
1

You can call tableView(_:didSelectRowAt:)

after selectRow(at:animated:scrollPosition:)

Vishal Sonawane
  • 2,637
  • 2
  • 16
  • 21
0

This will work for you.

tableView.delegate = self

In viewWillAppear() or after few milliseconds of viewDidLoad, call this:

tableView.selectRow(at: <IndexPath?>, animated: <Bool>, scrollPosition: <UITableViewScrollPosition>)

Share you full source code here, so can give you better suggestion.