How to create Grouped table

Discussion in 'iOS Programming' started by Narendar Singh, Jun 29, 2012.

  1. Narendar Singh macrumors member

    Narendar Singh

    Jun 22, 2012
    I know how to create Grouped Table, my basic understanding is that
    - first we need to set no of sections
    - then no of rows in each section
    - then actually row/cell creation based on section

    So what's wrong with me:
    In my application at run time I can have Zero or maximum 3 sections.
    I have 3 different array, based on their count I create sections.
    Row layout is different in each section, for say
    - section 1 row has 2 labels
    - section 2 row has 2 images
    - section 3 row has 3 labels

    I was bit confused to render my data in grouped table. any help or any idea would be helpful.
  2. cMacSW macrumors regular

    Mar 20, 2006
    In the cellForRowAtIndexPath you should set data appropriate for
    the row and section.

    So assuming that you're using standard uitableview cell then
    in section 1 you would set the label text like
    cell.detailTextLabel.text = labelText;

    for rows in section 2 set the images like:
    cell.imageView.image = rowImage;

    see this guide for more info
  3. PhoneyDeveloper macrumors 68040


    Sep 2, 2008
    The data model for a sectioned table is typically an array of dictionaries. Each dictionary represents a section. Each section dictionary has a title and an array of dictionaries. Each of these dictionaries represents a row.

    If you need custom cells then each kind of cell should have a different CellIdentifier.

    There's nothing in your description of what you want to do that is different between grouped tables and plain tables.
  4. Narendar Singh thread starter macrumors member

    Narendar Singh

    Jun 22, 2012
    Thanks guys for this information, enough to solve my problem.

Share This Page