views:

41

answers:

2

I have a UIViewController that is presented modally. The UIViewController is inside of a UINavigationController.

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];

    saveButton = [[UIBarButtonItem alloc] initWithTitle:@"Save" 
                                                  style:UIBarButtonItemStyleBordered 
                                                  target:self 
                                                  action:@selector(saveButtonClicked:)]; 


    self.navigationItem.rightBarButtonItem = saveButton;
    self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:(102.0/255.0) green:(20.0/255.0) blue:(11.0/255.0) alpha:1];
    self.title = @"Login";
    //toolbar.tintColor = [UIColor colorWithRed:(102.0/255.0) green:(20.0/255.0) blue:(11.0/255.0) alpha:1];
}

Why isn't my navbar appearing with the text Login and a save button to the right?

A: 

You set the properties after the nib is loaded, but you probably need to do it after/while it is pushed.

mvds
A: 

It sounds like you may be presenting the view controller instead of the navigation controller. Your code to present the view controller you've described should look something like this:

MyViewController *viewController = [[MyViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController];
[self presentModalViewController:navController animated:YES];
[viewController release];
[navController release];
Brian