Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

whitedragon101

macrumors 65816
Original poster
Sep 11, 2008
1,349
339
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:

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:
When you go back to A does it contain a new record that was just created. If you click that can you then edit the record from C.

If so I would implent c in a way that it can be used for editing and creating a new record.

If once added they records cannot be edited, I would use something allong the lines of presentViewController:animated:completion: to present B, when dismissed ARC should destroy it and then just transistion to C from A.

Hope this helps.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.