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

孤者浪人 提交于 2019-12-13 08:04:15

问题


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.


回答1:


self.view.hidden ? Eg In "B":

override func viewWillAppear(animated: Bool) {
    super.viewWillAppear(animated)
    if someFlag == true {
        self.view.hidden = true
    }
}



回答2:


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)
}


来源:https://stackoverflow.com/questions/31058371/how-to-present-several-uiviewcontrollers-at-once-making-visible-only-the-last-on

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!