I have the mainstoryboard + viewcontroller
When I press a button on the mainstoryboard it will show another storyboard.
When I press a button in the new storyboard I want to call a function of the mainstoryboard.
How can I make this happen?
I have the mainstoryboard + viewcontroller
When I press a button on the mainstoryboard it will show another storyboard.
When I press a button in the new storyboard I want to call a function of the mainstoryboard.
How can I make this happen?
You can grab the storyboard and instantiate a viewController from it like this:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"yourStoryboardName" bundle:nil];
YourViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:@"yourViewControllerIdentifier"];
But if you require a function that contains the context of the previous view controller, you should keep a reference to it and just call your methods directly from there. You can also use the presentingViewController
property to access the view controller that started the modal presentation. Or if using a navigationController you can use the viewControllers
property to access previous viewControllers in the stack.
The comment of Abizem gave me the right tag to search for.
'Protocols'.
I found a very good explanation here on stackoverflow.
Look there: How to access a previous story board.
Just have a look at the answer of Matt Price. Very nice explanation!