如何一次呈现多个 UIViewControllers 只显示最后一个? [英] How to present several UIViewControllers at once making visible only the last one?

查看:25
本文介绍了如何一次呈现多个 UIViewControllers 只显示最后一个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我需要做的:

假设我在视图A"处,我想显示视图C"但必须从B"呈现C".

Suppose I am at view "A", I want to show view "C" but "C" must be presented from "B".

即 A->B->C(这里没问题)

That is A->B->C (no problem here)

有什么问题?

我不希望 UIVIewController B 在这个序列中的任何时候都可见.

I don't want UIVIewController B to be visible at any time in this sequence.

推荐答案

我最后的猜测是使用诸如 view.layer.opacity 之类的属性(未测试)将 B 隐藏为透明,然后从 B 中呈现 C,最后在完成块中重置属性.

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.

更新:

听起来你想使用

func setViewControllers(_ viewControllers: [AnyObject]!, animation 动画: Bool)

文档:

使用此方法更新或替换当前视图控制器堆栈,而无需显式推送或弹出每个控制器.此外,此方法可让您更新控制器集而无需为更改设置动画,这在启动时可能适合您希望将导航控制器返回到先前状态.

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.

我想它看起来像这样:

self.setViewControllers( [self, B, C] , animated: true)

<小时>

你试过了吗:


Have you tried:

self.presentViewController(B, animated: false, completion: nil)
B.presentViewController(C, animated: false, completion: nil)

或者:

self.presentViewController(B, animated: false) { () -> Void in
    B.presentViewController(C, animated: false, completion: nil)
}

这篇关于如何一次呈现多个 UIViewControllers 只显示最后一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆