0

I have a button on my nib and would like to tell it to go to another nib page once it is selected.

Heres how it looks:

2 nibs.

nib1 has a button in the nav bar called 'btnHome'.

Once it is selected, I would like it to go to nib2.

How would I access the buttons controls to tell it to do this?

When in the nib design view, I cannot right click and drag from 'btnHome' to the other nib as normal - therefore the need to do this programatically.

Simagen
  • 409
  • 2
  • 8
  • 18

1 Answers1

1

You'll need to create an IBAction method on your first view controller whose purpose it is to present your second view controller (whose UI is defined in nib2). Then you'll need to instruct your nav bar button to send a message to your first view controller to execute that method when the button is pressed.

Your IBAction might look like this:

- (IBAction)didClickButton:(id)sender
{
    MyViewController2 *myVC2 = [[MyViewController2 alloc] initWithNibName:@"MyNib2Name" bundle:nil];    
    [self presentViewController:myVC2 animated:NO completion:nil];
}

Then, once you have done that, go to your nib1 and Control-drag from your nav button to your first view controller and select your IBAction method (didClickButton:) from the Sent Actions menu that will pop up.

Using storyboards makes this process easier.

jonkroll
  • 15,682
  • 4
  • 50
  • 43
  • Thanks Jon, I will try this now.. hope it works. fingers crossed. Otherwise Ill have to try the whole program again using storyboards.. – Simagen Sep 03 '12 at 21:11