IOS development: tableview of multiple sections

Source: Internet
Author: User

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)

Related Article

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.