0

For example when the numberOfRowsInSection method is called rather than when explicitly calling reloadData()

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 1;
    }

I am aware that this method is being fired when reloadData() is called. However I was wondering if anybody know when in the lifecycle these methods run automatically for the first time.

This is a curiosity kind of question if anyone happens to have looked into it.

Muzahid
  • 5,072
  • 2
  • 24
  • 42
Return-1
  • 2,329
  • 3
  • 21
  • 56

3 Answers3

1

Your tableview Delegate will call automatically multiple times

  1. When call of [UITableView didMoveToWindow]

  2. Other one from [UITableView layoutSubviews]

  3. Change of tableHeaderView view

See this for more info https://stackoverflow.com/a/4986682/4601900

Prashant Tukadiya
  • 15,838
  • 4
  • 62
  • 98
0

Normally func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int method is being called in ViewDidLoad.

Muzahid
  • 5,072
  • 2
  • 24
  • 42
0

It is automatically called for the first time when the view within which a tableView is contained is loaded by the viewController.

Prashant
  • 336
  • 3
  • 18