Search code examples
objective-ciosuinavigationcontrolleribaction

I have no Navigation Bar in a view called with an IBAction?


My main menu (a ViewController) is embedded in a NavigationController that I added in the storyboard in Xcode4. I have a button in my menu, displaying a new view. To display it I use :

- (IBAction) display : (id) sender
{
    if(!anotherView) anotherView = [[AnotherView alloc] initWithNibName:@"AnotherView" bundle:nil];
    [self presentModalViewController:anotherView animated:NO];
}

My other view is correctly displayed with all its objects and elements. Excluding my NavigationController's bar, that doesn't appear. Why ?

Thanks for your advices


Solution

  • You are presenting the view modally what you probably meant was

    [self.navigationController pushViewController:anotherView animated:YES]
    

    of course what you really want to do is not mix and match storyboard and non storyboard flows unnecessarily like this and have the storyboard do this for you