How to create Grouped table

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

  1. Narendar Singh macrumors member

    Narendar Singh

    Joined:
    Jun 22, 2012
    Location:
    INDIA
    #1
    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

    Joined:
    Mar 20, 2006
    #2
    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

    http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/TableView_iPhone/TableViewCells/TableViewCells.html%23//apple_ref/doc/uid/TP40007451-CH7-SW18
     
  3. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #3
    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

    Joined:
    Jun 22, 2012
    Location:
    INDIA
    #4
    Thanks guys for this information, enough to solve my problem.
     

Share This Page