I have a UINavigationController with a UITableViewController in it. I want to show a ToolBar on the bottom with UIBarButtonItem's. The ToolBar is showing up, but the buttons won't appear. Anyone knows why?
- (void)viewDidLoad {
[super viewDidLoad];
[[self navigationItem] setTitle:@"Selections List"];
[[self navigationItem] setRightBarButtonItem:[[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addProjectSearch:)] autorelease]];
[[self navigationItem] setLeftBarButtonItem:[self editButtonItem]];
[[super tableView] setDataSource: self];
[[super tableView] setDelegate: self];
//Toolbar
UIBarButtonItem * logoutButton = [[[UIBarButtonItem alloc] initWithTitle:@"Log out" style:UIBarButtonItemStylePlain target:self action:@selector(logOut:)]autorelease];
NSMutableArray * arr = [NSMutableArray arrayWithObjects:logoutButton, nil];
[[self navigationController] setToolbarHidden: NO animated:YES];
[[self navigationController] setToolbarItems:arr animated:YES];
}
Replace this line:
[[self navigationController] setToolbarItems:arr animated:YES];
with this:
[self setToolbarItems:arr animated:YES];
In general, you should set toolbarItems
on each individual view controller that you push, and not on your UINavigationController itself.