views:

64

answers:

3

UItableView style not changing. I have a tableView controller as one of the tabs of my tab bar controller. I am not able to change the style of UItableView to grouped.

Please help,

A: 

You can probably do that in your UITableViewControllers -viewDidLoad method.

self.tableView.style = UITableViewStyleGrouped;

Edit:

It seems the style property is actually read only, so the above won't work.

It looks like the table view controller has to be created with -initWithStyle:, but I don't know how to do that from Interface Builder. I'm not at my Mac right now, but will have a look later.

Edit 2:

Here's what I did in Interface Builder:

  1. Add an instance of UITableView and set it up as required, including the style
  2. Hook up your UITableViewController as the delegate and data source of the UITableView
  3. Connect the UITableView with the view outlet of the UITableViewController. I'm not sure if there is a tableView outlet - if there is, then probably connect it with that one instead.

So, basically, instead of letting the UITableViewController create its own table view, you provide one in the xib and set up the required connections (delegate, data source, outlet) manually.

Thomas Müller
Object cannot be set. Either read only property or no setter found
Bogus Boy
Are you working with a UITableViewController or a regular UIViewController? If it's not a TVC you have to create your own table.
MishieMoo
It's a table View Controller, yes.
Bogus Boy
+1  A: 

You must specify the Tableview's style upon creation. Either in IB or by using the method

tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0,320,416) style:UITableViewStyleGrouped];
Gubb
I created the table through IB and have tried changing the property to grouped, but to no avail. I mean how finicky is this x-code -- one day it behaves someway and the other day it's the exactly opposite. I have another application which runs fine with the same settings I am trying to get here.
Bogus Boy
A: 

I would create a new tableViewController and make sure to enable the "also create xib"-like option when giving the tableviewcontroller a name. Copy paste all youre old tablviewcontroller code to the new one and add the xib to the tab window..

Larsaronen