tags:

views:

203

answers:

1

I am trying to get a button on a navigation bar to load a new view, simple right? I have been unable to get it to work here is my code

- (IBAction)addAction:(id)sender
{
    NSLog(@"Button pressed");

    NSString *viewController = [[addViewController alloc] initWithNibName:@"AddView" bundle:nil];
    self.addViewController = viewController;
    [viewController release];
}

"Button pressed" shows up in the log this is just one off my chunks of code I tried to get this to work, I get a warning "passing argument 1 of 'setAddViewController' from distinct Object-C type" It should be simple but it can't get in to work, I am using Interface Builder so I am trying to load a nib. Thanks for your help

A: 

As you're probably in a navigation controller, you'll probably want to push it onto the navigation controllers stack:

[self.navigationController pushViewController: viewController animated:YES];
MathieuK
I added it, but it didn't change anything, the view isn't showing up at all.
Scott
Make sure you indeed have a navigationController at the point you're calling it by checking wether it's nil. If it is nil, you probably want to take another look at how navigation controllers work exactly.
MathieuK