user393553
user393553

Reputation:

UItableView + UItabbar

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,

Upvotes: 0

Views: 527

Answers (3)

LarsJK
LarsJK

Reputation: 2196

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..

Upvotes: 0

Thomas Müller
Thomas Müller

Reputation: 15635

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.

Upvotes: 0

Gubb
Gubb

Reputation: 421

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];

Upvotes: 1

Related Questions