Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the logical order of load methods of UITableViewController?

What is the logically executed order of a UITableViewController's methods when a segue is performed to show the tableView? Here is my best guess:

  1. viewWillLayoutSubviews
  2. numberOfSectionsInTableView
  3. numberOfRowsInSection
  4. cellForRowAtIndexPath
  5. heightForRowAtIndexPath
  6. viewDidLoad
  7. viewWillAppear
  8. viewDidAppear

Please correct this ordering and add to it.

like image 486
Christian Ayscue Avatar asked Jan 22 '15 06:01

Christian Ayscue


2 Answers

This may help you.

  1. viewDidLoad As it loads view first.

  2. viewWillAppear As any view appears again then this method is called.

  3. numberOfSectionsInTableView Sets number of sections in a table.

  4. numberOfRowsInSection After setting sections,this method determines number of rows in a section.

  5. heightForRowAtIndexPath Height for row will be set.

  6. viewWillLayoutSubviews View for section header is made.

  7. cellForRowAtIndexPath Contents and layout of cell of a tableview is created in this method.

  8. viewDidAppear

like image 98
iOSNoob Avatar answered Sep 30 '22 20:09

iOSNoob


If you have 1 row and 1 section. This is the pattern it goes through.

  1. viewDidLoad
  2. numberOfSectionsInTableView
  3. viewWillAppear
  4. numberOfSectionsInTableView
  5. numberOfRowsInSection
  6. heightForRowAtIndexPath
  7. viewWillLayoutSubviews
  8. numberOfSectionsInTableView
  9. numberOfRowsInSection
  10. heightForRowAtIndexPath
  11. viewWillLayoutSubviews
  12. viewDidLayoutSubviews
  13. viewDidAppear
like image 23
Abubakr Dar Avatar answered Sep 30 '22 21:09

Abubakr Dar