-1

I do row selection in my code

tbvCounters.selectRow(at: counterIndexPath, animated: true, scrollPosition: .middle)

and I assume that protocol method

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)

should be triggered but it`s not. It works fine when I tap the row of UITableView as user action. How I could simulate user tapping ti trigger "didSelectRowAt" method?

Dawy
  • 770
  • 6
  • 23
  • Possible duplicate of [How to programmatically "tap" a UITableView cell?](https://stackoverflow.com/questions/5918309/how-to-programmatically-tap-a-uitableview-cell) – Alex Bailey Dec 14 '18 at 18:24

1 Answers1

-2

selectRow doesn't trigger didSelectRowAt , but you can trigger with

tbvCounters.selectRow(at: counterIndexPath, animated: true, scrollPosition: .middle)
self.tableView(self.tbvCounters, didSelectRowAt: counterIndexPath)
Shehata Gamal
  • 98,760
  • 8
  • 65
  • 87
  • 2
    This is a bad idea. Never directly call delegate and data source methods. Put common in a function and call it as needed. – rmaddy Dec 14 '18 at 20:17
  • your suggestion is off-topic , here discussion about whether it's called or not and How To – Shehata Gamal Dec 14 '18 at 20:38