I am moving from one view controller to another but I will never go back the other way. i.e I have:
ViewControllerA //has a table view of records and a new record button
ViewControllerB //ask questions and store answers in datamodel + a finish button that segues to ViewControllerC
ViewControllerC //summary of answers and a button to go back to ViewControllerA
So ViewControllerB segues to ViewControllerC and never goes back and I don't know how to dismiss it.
I would like to do something like:
This seems to work. Is this ok to do?
This way of doing it seems to mean if you go through 2 screens after the program loads and then you never use them again they just remain taking up memory for no reason.
ViewControllerA //has a table view of records and a new record button
ViewControllerB //ask questions and store answers in datamodel + a finish button that segues to ViewControllerC
ViewControllerC //summary of answers and a button to go back to ViewControllerA
So ViewControllerB segues to ViewControllerC and never goes back and I don't know how to dismiss it.
I would like to do something like:
Code:
- (IBAction)buttonPressed_finish_inViewControllerB:(id)sender
{
//segue to next controller
[self performSegueWithIdentifier:@"toViewControllerC" sender:self];
//dismiss this controller (B) leaving the new controller (C) running
[self dismissViewControllerAnimated:YES completion:nil];
}
This seems to work. Is this ok to do?
Code:
// Simply allowing view controllers to pile up
// and then adding .presentingViewController as many
// times as is needed to get back to the one i want
[self.presentingViewController.presentingViewController dismissViewControllerAnimated:YES completion:nil];
This way of doing it seems to mean if you go through 2 screens after the program loads and then you never use them again they just remain taking up memory for no reason.
Last edited: