Search code examples
iphoneobjective-cuinavigationcontrollerpushviewcontroller

Push a view from a nib file using a right navigation bar button


As described in the title, i would like to push a view, from a known NIB, using a button on the navigation bar. I'm working on a UINavigationController app.

I already added the right button in IB and i linked it to the method that is in the RootViewController

I have searched everywhere but I couldn't find a way to do this method...

-(IBAction)addItems:(id)sender 
{
    ?
}

I also tried this solution, but it isn't working either...


Solution

  • For example:

    -(IBAction)addItems:(id)sender 
    {
        CustomController *controller = [[CustomController alloc] initWithNibName:@"CustomController" bundle:nil];
        [self.navigationController pushViewController:controller animated:YES];
        [controller release];
    }
    

    Where

    1. CustomController name of your custom controller class.
    2. @"CustomController" name of your xib file