Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When is tableView:numberOfRowsInSection: called in UITableView?

tableView:numberOfRowsInSection is sent to the delegate of a UITableView to find out how many rows it needs to have in a given section.

My question is, when and how often is this method called?

like image 898
Byron S Avatar asked Jun 04 '13 09:06

Byron S


People also ask

What is the function of the Tableview (_ Tableview Uitableview Numberofrowsinsection section int method?

Tells the data source to return the number of rows in a given section of a table view.

What is swift Numberofrowsinsection?

Returns the number of rows (table cells) in a specified section.


2 Answers

The method is called very first time the tableview is getting loaded and if you are more interested in the delegates then put a breakpoint and check when and where which delegate is called and how many times.

like image 116
Kasaname Avatar answered Oct 08 '22 15:10

Kasaname


Below are the instances when that function will get called,

  1. For the first time when table is loaded
  2. the time you reload the table data
  3. the time you add/update/delete your row or sections dynamically.
like image 38
Apurv Avatar answered Oct 08 '22 15:10

Apurv