Let\'s say I have 3 view controller labeled \"A\",\"B\" and \"C\". Right now, \"A\" is the rootViewController of the window and it presents \"B\" modally when a button is ta
You are taking about a Button lets name it controlButton. Pass that button with B and C with custom init method. That means your UIViewController A is having controllButton reference. Using the method
- (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents
set the trigger block in A and like this
[_controllButton addTarget:self action:@selector(controllButtonTapped:)....];
- (void)controllButtonTapped:(id)sender {
[self dismissViewControllerAnimated:YES completion:^{
// present you c here
[self presentViewController:c animated:YES completion:NULL];
}];
}
But the best option is to go with “Mediator Design pattern” where a coordinator is coordinating your present and dismiss actions.