Christian Ayscue
Christian Ayscue

Reputation: 697

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.

Upvotes: 5

Views: 3073

Answers (2)

Abubakr Dar
Abubakr Dar

Reputation: 4078

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

Upvotes: 8

iOSNoob
iOSNoob

Reputation: 1420

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

Upvotes: 10

Related Questions