- Introduction to Table View
- Sections
- Static VS Dynamic Tables
- UITableView Class
Introduction to Tab View
Table Views present the user with data in a list format and are represented by the UITableView class of the UIKit framework.
When implementing a View Controller that will control a TableView, you can subclass the UITableViewController class instead of UIViewController.
When implementing a View Controller that will control a TableView, you can subclass the UITableViewController class instead of UIViewController.
The data is presented in rows, whereby the content of each row is implemented in the form of a UITableViewCell object.
Sections
A table view presents data in a scrollable list of multiple rows that may be divided into sections.
The UIKit framework identifies rows and sections through their index number: Sections are numbered 0 through n - 1 from the top of a table view to the bottom; rows are numbered 0 through n - 1 within a section.
By default, each table cell can display a text label (textLabel), a subtitle (detailedTextLabel) and an image (imageView).
Static VS Dynamic View
Static tables are useful in situations when a fixed number of rows need to be displayed in a table.
Dynamic tables (also known as prototype-based tables), on the other hand, are intended for use when a variable number of rows need to be displayed from a data source. Within the storyboard editor, Xcode allows you to visually design a prototype table cell which will then be replicated in the dynamic table view at runtime in order to display data to the user.
Each table view in an application needs to have a delegate and a dataSource associated with it (with the exception of static tables which do not have a data source).
The dataSource implements the UITableViewDataSource protocol, which basically consists of a number of methods that define title information, how many rows of data are to be displayed, how the data is divided into different sections and, most importantly, supplies the table view with the cell objects to be displayed.
The delegate implements the UITableViewDelegate protocol and provides additional control over the appearance and functionality of the table view including detecting when a user touches a specific row, defining custom row heights and indentations and also implementation of row deletion and editing functions.
No comments:
Post a Comment