UITableView is the most frequently used view in iOS.
I. Components of the UITableView
1. UITableView initialization
UITableView has two protocols:
1) DataSource is a Uitableviewdatasource type that provides display data (UITableViewCell) primarily for UITableView, specifying the type of edit operation supported by UITableViewCell (insert , delete and reordering), and the corresponding data update operation according to the user's operation, if the data does not have more action to correct the update, may cause the display exception, even crush.
2) delegate is a uitableviewdelegate type that provides some optional methods to control the selection of TableView, to specify the head and tail of the section, and to assist in the removal and sequencing of cells.
There are two styles of UITableView:
1) Plain, mainly used for dynamic tables, while dynamic tables are generally used in cases where the number of cells is unknown.
2) grouped, used for static tables, can be grouped into groups of cells.
UITableView can only have one column of data and can only support portrait sliding.
1 // create tableview based on frame and style 2 UITableView * TableView = [[UITableView alloc] Initwithframe:cgrectmake (00, [UIScreen mainscreen ].bounds.size.width, [UIScreen mainscreen].bounds.size.height) Style:uitableviewstyleplain]; 3 TableView. delegate = self ; 4 Tableview.datasource = self ; 5 self.table = TableView; 6 [Self.view Addsubview:tableview];
2. Table Header View
The header view is the topmost view of the UITableView, often used to display information about the table view, as well as to display pictures, carousel diagrams, and so on.
We need to use @property (nonatomic, retain) UIView *tableheaderview; this property.
1 // Initialize head view 2 UIView * view = [[UIView alloc] Initwithframe:cgrectmake (00)]; 3 View.backgroundcolor = [Uicolor redcolor]; 4 Self.table.tableHeaderView = view;
3. Table-foot View
The table foot view is the bottom-most view of UITableView, which is used to display information about a table view, typically to show "more" information, or to identify special actions such as buttons.
We need to use the attribute @property (nonatomic, retain) UIView *tablefooterview property.
1 // Initialize the view of the table feet 2 UIView * Footview = [[UIView alloc] Initwithframe:cgrectmake (00)]; 3 Footview.backgroundcolor = [Uicolor bluecolor]; 4 Self.table.tableFooterView = Footview;
To be continued .....
iOS Learning Note--uitableview