I am wondering why my UINavigationController is not letting me set a title. It lets me change the tint of the navigationBar, but the title and rightBarButtonItem I set just get ignored. Why?
Here’s my code:
taps = 0;
UIView*controllerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
controllerView.backgroundColor = [UIColor whiteColor];
controller = [[UIViewController alloc] init];
[controller setView:controllerView];
[controllerView release];
navController = [[UINavigationController alloc] initWithRootViewController:controller];
navController.navigationBar.barStyle = 1;
navController.navigationItem.title = @"Setup";
UIBarButtonItem*item = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonSystemItemDone target:self action:@selector(dismissSetup:)];
navController.navigationItem.rightBarButtonItem = item;
[item release];
[self presentModalViewController:navController animated:YES];
[mp stop];
p.s: I know i’m not releasing some of the stuff I alloc’ed, I do that later!
You want your UINavigationController to change its title depending on which viewcontroller is currently on top. So the way to go is to set the title in the viewcontrollers you are pushing onto the viewControllers array.
And by the way: I don’t think navigationcontrollers are supposed to be presented modally: