Develop the tableview of multiple sections.
First, consider how to obtain the data source.
Here we can use two methods: the first is to read the plist file. The second is to store and read data through code.
The data source required by multiple sections is a dictionary, and the content in the dictionary is an array. In the plist file, you can create
Define a dictionary and an array in the. h file
In the viewdidload function of the. M file:
Explanation: Get the sandbox of the entire program through bundle, create an nsurl object, read it into a dictionary, and store all the dictionary keys in an array.
The next step is to implement the tableview proxy and data source functions.
The number of sections is the Count value of the dictionary heavy element;
The number of rows in each section is the Count value of the corresponding array of dictionary elements.
The content in cellforrowatindexpath is directly displayed.
Add a title to each section of tableview as follows:
The index column on the Right of tableview is to be added as follows:
The effect is complete:
Let's see the results.
The right side is when the index bar is pulled.
Download source code: grouptabledemo (please comment on the download. Thank you)