iOS Learning Note--uitableview

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.