Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UINavigationController Title not Applied

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!

like image 873
Pripyat Avatar asked Nov 22 '25 09:11

Pripyat


1 Answers

set: self.title = @"This is my title"; in the viewController

(or in your case set controller.title = @"this is my title";)

like image 178
Thomas Clayson Avatar answered Nov 24 '25 22:11

Thomas Clayson