What you have to do is a property in the second view controller, for example:
@property (nonatomic, assign) NSInteger buttonSelected;
On the first view controller, when you instantiate the second view controller:
- (IBAction)onBtn1:(id)sender
{
UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil];
UIViewController vc2 = [storyboard instantiateViewControllerWithIdentifier:@"TDSecondViewController"];
vc2.buttonSelected = 1;
[self.navigationController pushViewController:vc2 animated:YES];
}
For each button, you can set a different value of vc2.buttonSelected.
On the second view controller, in viewDidLoad:
- (void)viewDidLoad {
if (_buttonSelected == 1) {
// do something
} else if (_buttonSelected == 2) {
// do something else
}
//... and so on...
}
Some things to notice:
- Replace UIViewController for the actual class of the view controller being pushed
- You can obtain the storyboard by doing self.storyboard, seems easier :)