iOS Noob
iOS Noob

Reputation: 3

Popping or removing modals after segues

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

Upvotes: 0

Views: 81

Answers (2)

Mark
Mark

Reputation: 7419

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.

Upvotes: 0

Andrew McKinley
Andrew McKinley

Reputation: 1137

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.

Upvotes: 0

Related Questions