On 01/12/2010, at 5:02 PM, Donald Hall wrote:

> the root view controllers for each navigation controller are custom 
> UITableViewControllers.
> 
> What is the best way to set the style of the table views? I want at least one 
> of my table views to have a grouped style, but I can see no easy way of 
> specifying this.

The (UITableView*)tableView object in a UITableViewController is created when 
it's needed. So you won't see it in the default nib. The style of the tableView 
can only be set when it is created. If you want to customize the creation of 
the tableView, you can do it either of two ways:

1. Add you own UITableView object (with the group style, if you want it) in the 
UITableViewController's nib and hook it up to the UITableViewController's 
tableView outlet.

or:

2. Intercept the dynamic creation of the tableView in code, overriding the 
style of the created table. In the code of your subclass of 
UITableViewController, add this (or just uncomment and tweak it if it's already 
there from the template):

- (id)initWithStyle:(UITableViewStyle)style
{       // Override initWithStyle: if you create the controller 
programmatically and want to perform customization that is not appropriate for 
viewDidLoad.
        self = [super initWithStyle:UITableViewStyleGrouped];
        if (self != nil)
        {
                // any further customizations here
        }
        return self;
}


Here's the relevant documentation for the IUTableViewController class:

initWithStyle:
Initializes a table-view controller to manage a table view of a given style.

- (id)initWithStyle:(UITableViewStyle)style
Parameters
style
A constant that specifies the style of table view that the controller object is 
to manage (UITableViewStylePlain orUITableViewStyleGrouped).
Return Value
An initialized UITableViewController object or nil if the object couldn’t be 
created.
Discussion
If you use the standard init method to initialize a UITableViewController 
object, a table view in the plain style is created.

Hope this helps,
Tom
BareFeetWare
Coming soon: SQLite schema and data editor for 
iOS_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to