I have a MainViewController which has a ContainerView inside, it shows ViewControllerA.
Is there a method to go from UIViewControllerA to UIViewControllerB in the ContainerView?
Hierarchy is:
MainViewController -> containerView
ViewControllerA -> btnShowViewControllerB
ViewControllerB
Codes are:
// MainViewController.m
- (void)viewDidLoad {
[super viewDidLoad];
// Show ViewControllerA in the ContainerView programmatically
ViewControllerA *vcA = [self.storyboard instantiateViewControllerWithIdentifier:@"A"];
[self addChildViewController:vcA];
[self.containerView addSubview:vcA.view];
[vcA didMoveToParentViewController:self];
}
// ViewControllerA.m
- (IBAction)btnShowViewControllerB:(UIButton *)sender {
}
Thank you
This is how you can switch viewControllers programmatically: