I'm trying to present modally a UITableViewController from a view controller in my navigation controller hierarchy. The modal view should display a toolbar.
Can the navigation controller's managed toolbar be used in view controllers presented modally or should I implement my own toolbar for these?
[self.navigationController presentModalViewController:filterVC animated:YES];
no toolbar is displayed.[self.navigationController pushViewController:filterVC animated:YES];
the toolbar is displayed.Here is the method I run from the init method of my UITableViewController.
-(void)configureToolBar {
[self.navigationController setToolbarHidden:NO animated:YES];
//ToolbarItem Done
UIBarButtonItem *doneItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone
target:self
action:@selector(doneButtonPressed)];
//ToolbarItem Cancel
UIBarButtonItem *cancelItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
target:self
action:@selector(cancelButtonPressed)];
//Flexible Space
UIBarButtonItem *flexibleItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
self.toolbarItems = [NSArray arrayWithObjects:flexibleItem, cancelItem, doneItem, flexibleItem, nil];
[doneItem release];
[cancelItem release];
[flexibleItem release];
}
No, you can't, because a modal view controller becomes a child to the view controller that displays it, and this view controller is a subview of the navigation controller (i.e. the modal view has no connection with the NavigationController's hierarchy). You can present a navigation controller as a modal view controller, though, so you can pass your custom navbar buttons to it.