I'm using storyboard and I have a view that loads dynamic buttons. On click of this button, I need to load the second view controller and also pass data. I cannot use segue as its dynamic button.
I use following code to load the second view controller
UIStoryboard* sb1 = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone"
UIViewController* vc1 = [sb1 instantiateViewControllerWithIdentifier:@"SecondViewController"];
[self.navigationController pushViewController:vc1 animated:YES];
You can create a Segue not bounded to a button by ctrl+drag from the first controller to the second one (don't forget to give this segue and identifier).
Next In the IBAction of the button (set via Interface Builder or via
addTarget:self action:forControlEvents: ) you can call the
[self performSegueWithIdentifier:@"YourSegueIdentifier" sender:button];
You can pass the data to the second controller, as usual, in
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender