0
votes

I have 3 view controllers in storyboard. VC1 is connected to VC2 via segue and VC3 is connected to VC2 via the same. The segues are implemented in IBAction button clicks with "self.performSegueWithIdentifier". VC2 and VC3 have translucent backgrounds and are presented modally and over current context.

I am trying to figure out how to remove the VC1 from the stack of views once VC3 is presented. I don't have any complicated code. Please see the link for an image that further explains the problem.

enter image description here

2
Do you want to hide it, or remove it completely from the stack (i.e. when you dismiss VC3 and VC2, do you want VC1 to be shown)? If it's the former, than you can control the transparency of VC2. If it's the latter, you won't be able to accomplish that with standard transitions, and you'll probably want to look into creating a custom container view controller.Mark
Thanks for the reply, guys. Mark, I'm looking into container views right now. Andrew, The images are from a much simpler app. The real app has a lot of UI elements on each VC so using views instead of VCs will make the screen cluttered.iOS Noob
Since i ended up using container views, I think Mark's response should be the answer.iOS Noob
I'll write up an official answer tonight.Mark

2 Answers

0
votes

I looked at the image you uploaded. If two or all three VC's are visible at the same time then why are you using UIViewControllers instead of UIViews? If it is supposed to look like the image then there should be only 1 UIViewController maintaining everything. Everything that you are using VC's for should just be normal UIViews. When the user hits next, instantiate the view and animate it on the screen to simulate the next page animation. Having multiple UIViewControllers visible and active is highly unorthodox and not recommended.

If you have some excellent reason for multiple visible VC's I would recommend having VC1 listen for an NSNotification that can be sent by VC3 or any relevant class that will tell VC1 to dismiss itself.

0
votes

In order to fully control the transitions between VC1, VC2, and VC3, I would recommend using a Container View Controller.

In particular, you can remove VC1's view from the view hierarchy when presenting VC3.

You can find more information on implementing a container view controller here.