How to present several UIViewControllers at once making visible only the last one?

时间:2015-06-25 18:45:26

标签: ios xcode swift segue

This is what I need to do: Suppose I am at view "A", I want to show view "C" but "C" must be presented from "B". That is A->B->C (no problem here) What's the issue? I don't want UIVIewController B to be visible at any time in this sequence.

2 个答案:

答案 0 :(得分:1)

My last guess would be to hide B with transparency, using some property like view.layer.opacity (not tested), then present C from B, and finally reset the property in the completion block. Update: Sounds like you want to use func setViewControllers(_ viewControllers: [AnyObject]!, animated animated: Bool) Docs: Use this method to update or replace the current view controller stack without pushing or popping each controller explicitly. In addition, this method lets you update the set of controllers without animating the changes, which might be appropriate at launch time when you want to return the navigation controller to a previous state. I guess it would look something like this: self.setViewControllers( [self, B, C] , animated: true) Have you tried: self.presentViewController(B, animated: false, completion: nil) B.presentViewController(C, animated: false, completion: nil) or alternatively: self.presentViewController(B, animated: false) { () -> Void in B.presentViewController(C, animated: false, completion: nil) }

答案 1 :(得分:1)

self.view.hidden ? Eg In "B": override func viewWillAppear(animated: Bool) { super.viewWillAppear(animated) if someFlag == true { self.view.hidden = true } }