0

When presenting a UIViewController using a button on Xcode through code, you usually use

[self presentViewController:viewControllerInstance animated:YES completion:nil];

Normally, before presenting the viewControllerInstance, I can make changes to that instance like setting some of its properties. However, this time I am using storyboard, and I was wondering how I would access the instance of the view controller being presented if it's not being created in code? I'd like to be able to set some properties of that specific UIViewController?

Thank you in advanced!

Jay Bhalani
  • 4,142
  • 8
  • 37
  • 50

1 Answers1

2

In your UIViewController, add this callback method in .m file:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    if ([segue.identifier isEqualToString:@"Segue_Identifier"]) {

        YourViewController *dest = segue.destinationViewController;

        //dest.yourProperty = ...; set your presenting view controller's properties
    }
}
tounaobun
  • 14,570
  • 9
  • 53
  • 75