Table view is the most frequently used view in iOS development, and we generally choose to display the data in the form of a table, such as Address Book, channel list, etc. Table View segmentation, grouping, indexing and other functions so that we show the data looks more regular and more conditioning, and more exciting is the table view can also use the details of the display of features such as multi-level display data, is called a table victory thousand words. However, compared to the other controls table view is more complex, but compared with the table view of the various flexible features, we spend on the effort is quite worthwhile.
Simple table View
Table view of the form of flexible, in line with the principle of simplicity, we first start from the simple table view to learn. The simple table view in this section is a dynamic table (all dynamic tables have no dynamic table and static table differences before IOS 5).
Create a simple table view
After iOS 5 we can use Xib or storyboard technology to create a table view, to show the most basic table, we only need to implement the Uitableviewdatasource protocol must be implemented, respectively, TableView: Numberofrowsinsection: And Tableview:cellforrowatindexpath: It's OK. :
Constructor Initwithframe:style: Called when the table view is instantiated, if the table view is designed with a xib or storyboard, the creation of the table view is done when the table view controller is instantiated, and the table view displays TableView when it is displayed: Numberofrowsinsection: The message asks for the number of rows in the current section, and the table view cell displays Tableview:cellforrowatindexpath: The message provides display data for the cell.
We create a simple table view with the default style for the cell, with the icon and the main title, which shows the World Cup team information.