So, I have 3 view controllers in the storyboard (VC1, VC2 and VC3).
Each view has a button that calls IBAction, which calls this method to switch to another view:
[self doSegue: myViewController_ID]; -(void) doSegue:(NSString *)_myViewController_ID { //get UiViewController from storybord with Unique ID UIStoryboard *storyboard = self.storyboard; UITableViewController *svc = [storyboard instantiateViewControllerWithIdentifier:_myViewController_ID]; //set presentation & transition styles svc.modalPresentationStyle = UIModalPresentationFullScreen; svc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; //do segue [self presentViewController:svc animated:YES completion:nil]; }
Lets set that I go from VC1 to VC2, once on VC2
I want to delete the previous ViewController (VC1). and if I now switch to VC3 from VC2, I want to remove the VC2 stack or view from the hierarchy, etc.
This is because I will not offer the method [self dismissViewControllerAnimated:YES completion:nil];
I do not want the memory to grow as a result of the accumulation of the controller in the stack.
NOTE. I will not use the navigation controller or the tab controller, only the view controller.
Thank you for your help.
source share