Skip to content

Latest commit

 

History

History
44 lines (30 loc) · 2.61 KB

2015_07_25.md

File metadata and controls

44 lines (30 loc) · 2.61 KB

Objective

  • Understand the use case of a UITableViewController
  • Ability to implement a UITableView with static UITableViewCells

View controller lifecycle

https://medium.com/@SergiGracia/ios-uiviewcontroller-lifecycle-261e3e2f6133

- viewDidLoad
Called after the controller’s view is loaded into memory.

It’s only called when the view is created. Keep in mind that in this lifecycle step the view bounds are not final. Good place to init and setup objects used in the viewController.

- viewWillAppear:
Notifies the view controller that its view is about to be added to a view hierarchy.

It’s called whenever the view is presented on the screen. In this step the view has bounds defined but the orientation is not applied. This event is called every time the view appears so don’t add code here which should be executed just one time (or manage it correctly).

- viewWillLayoutSubviews
Called to notify the view controller that its view is about to layout its subviews.

This method is called every time the frame changes like for example when rotate or it’s marked as needing layout. It’s the first step where the view bounds are final. If you are not using autoresizing masks or constraints and the view size changes you probably want to update the subviews here.

viewDidLayoutSubviews
Called to notify the view controller that its view has just laid out its subviews.

Make additional changes here after the view lays out its subviews.

viewDidAppear:
Notifies the view controller that its view was added to a view hierarchy.

Good place to perform additional tasks associated with presenting the view like animations. This method is executed after the animation displaying the view finishes so in this step the view is already visible for the user. In some cases can be a good place to load data from core data and present it in the view or to start requesting data from a server.

viewWillDisappear:
Notifies the view controller that its view was will disappear.

viewDidDisappear:
Notifies the view controller that its view was will disappear.

UITableViewController

https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITableViewController_Class/

The UITableViewController class creates a controller object that manages a table view.

UITableView

https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITableView_Class/

An instance of UITableView (or simply, a table view) is a means for displaying and editing hierarchical lists of information.