开发者

UINavigationController from scratch?

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.

A开发者_运维百科ll 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)


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜