views:

498

answers:

2

I want the first view in my UINavigation Controller grouped, but I can't see where to initWithStyle as UITableViewStyleGrouped.

My MainWindow.xib is set up like:

File's Owner (Outlets: delegate-Test App Delegate)

First Responder

Test App Delegate (Class: TestAppDelegate) (Outlets: navController-Navigation Controller, testListController-Test List Table View, window-Window, delegate-File's Owner)

Window (Outlets: window-Test App Delegate)

Navigation Controller (Class: Navigation Controller) (Outlets: navController-Test App Delegate)

-Navigation BAr

-Test List Table View Controller (Class:TestListTableViewController) (Outlets:testListController-Test App Delegate)

-- Naviagtion Item (Class: UINavigationItem)

The code:

// TestAppDelegate.h
@class TestListTableViewController;

@interface TestAppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
    TestListTableViewController *testListController;
    UINavigationController *navController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet TestListTableViewController *testListController;
@property (nonatomic, readonly) IBOutlet UINavigationController *navController;

@end


// TestAppDelegate.m
- (void)applicationDidFinishLaunching:(UIApplication *)application {
    [window addSubview:navController.view];
    [window makeKeyAndVisible];
} // etc
A: 

Open up IB, select the Table View within Test List Table View Controller (Class:TestListTableViewController) and in the Inspector window, go to the Attributes (first) tab and change the style from Plain to Grouped

JoostK
The is no Table View within Test List Table View Controller. If I put one in, the programs gives an 'internal consistency' error when run.
cannyboy
There must be a Table View in the Table View Controller. TestListTableViewController is a table view controller, which view must be a UITableView. Change your View Mode in IB's main window to list view, and you can easily find all the subviews.If that doesn't work, drag a new UITableViewController object to the UINavigationController object, set it's class to TestListTableViewController and try it again. Something must have gone wrong.
JoostK
No, there is no Table View. I'm trying to base my program on this Apple Sample Code: http://developer.apple.com/iphone/library/samplecode/iPhoneCoreDataRecipes/index.html (but without the Tabs). You can see in that code that there is no Table View in the MainWindow.xib. I'm a bit confused about how the Table gets created.
cannyboy
Here's my Objects outline: http://www.imgdumper.nl/uploads2/4ab65947df3b2/4ab65947d344b-Schermafbeelding_2009-09-20_om_18.30.02.png. Maybe you can show yours or manage it the same way I did to test if it then works. Good luck!
JoostK
this pic shows the coredatarecipes sample code xib from apple (top) and my xib (bottom). I put the Table View in my version even though it does nothing. You can see that the Apple xib does not have a Table View in the xib. If I can work out how the table gets initialized in the Apple code then I think my problem will be solved. http://img185.imageshack.us/i/screenshot20090920at174.png/
cannyboy
according to the docs: http://developer.apple.com/iphone/library/documentation/uikit/reference/UITableViewController_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40007523-CH3-DontLinkElementID_1 UITableViewController automatically creates its own UITableView if no xib is specified. So I just need to find a a way to initWithStyle somewhere, somehow, some time... but as far as I can see there is no way to do it
cannyboy
Well, when I drag a new UITableViewController object to the UINavigationController, I get a UITableView instance within the table view controller, which is the view of the table view controller. You can then adjust that table view's style within IB and it should be fine. There really is a UITableView instance listed, if it isn't, create your nib all over again (or at least drag in a new table view controller)
JoostK
that doesn't work with the sample code i am trying to use http://developer.apple.com/iphone/library/samplecode/iPhoneCoreDataRecipes/index.html
cannyboy
A: 

or programmatically you can use this initializer:

initWithFrame:style:

ennuikiller