views:

25

answers:

2

I am creating an application which I want to have a view controller with buttons as the first view controller with no navigation bar, and then when the user selects a button a table view controller appears managed by a navigation controller.

At the moment I am setting up the navigation controller in the app delegate and setting the top view controller as the table view controller I want to start the navigation bar on. So far I can see the navigation bar but that is it when I transition from the first view controller to the table view controller.

Any help would be much appreciated as I have confused myself with this issue.

A: 

I'm not totally clear on what you are asking, so I might have it wrong, but here goes. The top navigation bar is can be displayed or hidden by calling:

self.navigationController.navigationBarHidden = NO;

In the viewWillAppear method of your viewController. So set it to YES or NO depending on whether or not you want it to be displayed.

joelm
Thanks for the reply. I realise how confused that sounded but didnt really know how to explain it.When you create a new project using xcode as a table view project it sets everything up with the navigation controller already. I want to do the same apart from I want a view controller handling a view before that thats not handled by the navigation controller and doesnt have a navigation bar.
Disco
A: 

@Disco, you would do something like so:

// In the App delegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
  CustomViewController *viewController = [[CustomViewController alloc] init];
  [window addSubview:viewController.view];
  [window makeKeyAndVisible];
  return YES;
}

// In your button method
- (IBAction)loadUpTableViewController:(id)sender {
  CustomTableViewController *tvc = [[CustomTableViewController alloc] init];
  UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:tvc];
  [self presentModalViewController:navigationController animated:YES];
  [navigationController release];
  [tvc release];
}
charlie hwang