What is the logical order of load methods of UITab

2019-02-15 11:34发布

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.

2条回答
别忘想泡老子
2楼-- · 2019-02-15 12:17

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

查看更多
劳资没心,怎么记你
3楼-- · 2019-02-15 12:20

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
查看更多
登录 后发表回答