0
votes

If I use the Empty template in Xcode, which just gives an app delegate and window, and I want to have a UITableView with navigation bar for drilling up and down, am I correct in assuming I should just do as below, create a UITableView subclass, instantiate it, then instantiate a navController, set the TableView as the navControllers root view and then add the navController as the root view of the Window?

It seems wrong to create a UITableViewController only to add this to another view controller subclass (UINavigationController).

Is this correct?

    MyTableViewController *myTableViewController = [[MyTableViewController alloc] initWithNibName:@"MyTableViewController" bundle:nil];

    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:MyTableViewController];

    [self.window setRootViewController:navController];
3
Note that there is a UITableViewController and a UITableView. The former is just like any other view controller, while the latter is a "view" and can be added to other views (including a view controller's view) just like a label can. You might want to consider which serves your purposes better.Hot Licks

3 Answers

1
votes

Yes it's correct. The navigation controller is a container whose purpose is to manage a stack of view controllers so it's very different to the table view controller. Try the master detail template and compare the differences.

1
votes

You are correct. I'd also recommend you use a table view framework (such as the free Sensible TableView) to manage all your detail view controllers instead of you having to create them manually.