views:

99

answers:

1

I have a view based app that works well. (In other words, I'm not going to start over with a Navigation-Based App template.)

It's an immersive app of sorts and I'm trying to add a Table View that loads in a new view when a button is pressed.

The loading the nib part works, but I can't seem to be able to add a navigation controller to the new view. I want to see a navigation bar on top with a done button and an edit button. Also, I want to the Table View entries to be empty.

  • I added a new file like so: File-> New File -> UINavigationController subclass. I checked the UITableViewController Subclass and With XIB for user interface.

All I see when the view is pulled up is a blank Table View. I am able to customize things in the view controller.

What can I do to make the table show a navigation bar and be editable? I need some direction here please.

EDIT: I'm working with the latest Public SDK. (XCode 3.2.2)

+2  A: 

The navigation bar usually comes with a navigation controller, not with the table view controller.

You can add the navigation bar manually, but that will require altering the table view, to change it to just a regular view with a table view inside of it, and changing your table view controller to be a regular view controller that manually handles the table view stuff.

The simpler alternative is to wrap your table view controller inside of a navigation controller before you display it. Something like:

MyTableViewController *myViewController = [[MyTableViewController alloc] init];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:myViewController];
[myViewController release];

//Now display navigationController instead of myViewController, using something like:
[self presentModalViewController:navigationController animated:YES];
Ed Marty
Is `initWithRootViewController` a convenience method that will automatically release itself when finished?
Moshe
It just creates a navigation controller object that contains a view controller (in this case the table view controller). However, since it's an init method, you'll need to release it yourself later.
BoltClock