【问题标题】:Unwind then segue without showing intermediate view controller在不显示中间视图控制器的情况下展开然后继续
【发布时间】:2018-01-29 05:37:51
【问题描述】:
我有三个UIViewControllers,其中 A -> B -> C 和 A -> D。
当用户在 C 中完成时,我想放松回到 A,然后转到 D,但是如果在转到 D 之前短暂显示 A,我就无法让它工作。我已尝试禁用 segue 的 animates 属性,但 A 仍会在不到一秒的时间内闪现。
知道如何解决这个问题吗?
【问题讨论】:
标签:
ios
uiviewcontroller
uistoryboardsegue
unwind-segue
【解决方案1】:
在 swift 3 中试用此代码:-
let oldVCs = self.navigationController?.viewControllers
var newVCs = [UIViewController]()
// Add your root VC in new array of VCs
newVCs.append(oldVCs![0])
// Add your new VC just after your root VC
newVCs.append("Your New VC")
self.navigationController?.setViewControllers(newVCs, animated: true)