how to make tableViewController's table grouped style

Discussion in 'iOS Programming' started by Howiieque, Sep 6, 2009.

  1. Howiieque macrumors regular

    Joined:
    Feb 1, 2009
    #1
    hi.
    do you know how to make tableViewController's table grouped style.
    that table was generate by the tableViewController instead of laying in the interface builder.
     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
  3. Howiieque thread starter macrumors regular

    Joined:
    Feb 1, 2009
    #3
    thank you.

    but yes, i know there is two style. and i don't know how to achieve it.
    i have a navigation controller, and then i give it a table view controller. the table view controller will automatically create a table view for me. but that table is plain style. i can't find a way to make it group style.
    please help.
     
  4. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #4
    If you create your table view controller in code then use initWithStyle: If you us IB there is a checkbox for the style.
     
  5. Howiieque thread starter macrumors regular

    Joined:
    Feb 1, 2009
    #5
    thank you.


    but the fact is that i subclassed the table view controller and specify it to navigation controller in the interface builder. so it is the navigation controller to make an instance of the table view controller. and then i have no chance to send initWithStyle: to that table view controller. i have tried to override the init and initWithStyle in my class, though. but that took no effect.
    please give more detail help.
     
  6. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #6
    If the table view controller is built in your nib then I think the table is also included in the nib. The inspector window for the table shows a style popup. Choose grouped, not plain.
     
  7. hal 2010 macrumors newbie

    Joined:
    Mar 15, 2010
    #7
    Hi, did anyone solve this yet?

    To reiterate:-

    The subclass of UITableViewController is instantiated automatically in IB by a Navigation Controller (within mainWindow.xib)

    There is therefore no table view to select to enable the group option to be checked.

    As such (the NavigationController within IB) does not call the initWithStyle: method. I've checked.

    My version is a Tab bar controller with a Navigation Controller view controller for each tab which in turn automatically creates a UITableViewController subclass instance. This automatically creates a table view without need for a table view in the window.

    What hook can I use to catch the Navigation Controller before it pushes the UITableViewController subclass instance and therefore utilize initWithStyle:?
     
  8. Luke Redpath macrumors 6502a

    Joined:
    Nov 9, 2007
    Location:
    Colchester, UK
    #8
    If you're taking the NIB-approach, then presumably in your MainWindow.nib, you have a UINavigationController (or a UITabBarController) with a root view controller (or a controller for each tab).

    First of all, create a new view NIB for your UITableViewController sub-class. Then, select the root view controller in your MainWindow.nib and in the inspector, under "NIB Name", enter the name of your custom NIB.

    It should look something like this:

    [​IMG]

    This root view controller is your custom UITableViewController sub-class.

    Now open the view NIB you just created. Delete the empty view and drag in a UITableView. Select the File's Owner object and set its class to your UITableViewController sub-class in the inspector panel:

    [​IMG]

    You can now select the table view and play about with its properties in the inspector panel.

    Finally, don't forget to hook up the table view outlets; it should be set as the view for the File's Owner, and the File's Owner should be set as the delegate and dataSource for the table view.

    [​IMG]
     
  9. Lakeside Louie macrumors newbie

    Joined:
    Aug 3, 2010
    #9
    Perfect Answer

    Luke,

    Thanks for the answer. I was trying to modify the master tableview on a splitview and this was just what I was looking for.
     

Share This Page