Reputation: 2352
I have a UITableViewCell created in an external Nib from my storyboard. I have set up a segue from the UITableViewController to another ViewController which works nicely when tested.
I was wondering how would I get the UIButton in the Nib to call
[performSegueWithIdentifier:@"identifier" sender:self];
when it's pressed.
Any ideas? I'm still very amateurish so if you could explain quite clearly I'd really appreciate it.
Regards,
Mike
Upvotes: 1
Views: 308
Reputation: 2538
You can also accomplish the same thing on the storyboard; right click the button and drag the arrow to the viewcontroller you want to navigate to, it will give the segue options (push, modal, custom) and just select one.
Upvotes: 1
Reputation: 4409
To handle it in your calling VC
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:@"identifier"]) {
>yoursecondVC> *secondViewController = [segue destinationViewController];
secondViewController.<param> = <param>;
}
}
Upvotes: 0
Reputation: 422
In your ViewController.h do this:
- (IBAction)buttonPressed:(id)sender;
In your .m file do this:
- (IBAction)buttonPressed:(id)sender {
[self performSegueWithIdentifier:@"identifier" sender:self];
}
Now go to your .xib
File and connect the Buttons selector to your controller.
Upvotes: 1