gpt4 book ai didi

ios - 如何从另一个导航 Controller 在导航 Controller 中的根 vc 之上呈现 View Controller

转载 作者:行者123 更新时间:2023-11-28 10:50:57 27 4
gpt4 key购买 nike

我正在为一个系统注册一个用户,当他们注册时我希望他们通过一个教程,这个教程已经在 HomeVC 中以几种不同的方式呈现。我不想创建教程的克隆并将其粘贴到注册过程中,我认为这是简单的出路。寻找最佳实践:)

所以在注册后这就是我正在做的

 //0. Currently in "Signup" Nav stack
//1. init VCs for new nav stack
//2. push tutorial onto HomeVC nav w/o animation
//3. present stack with HomeVC below Tutorial, but tutorial is what animates in since in on top?


//@1.
let HomeVC = UIStoryboard(name: "Home", bundle: nil).instantiateViewController(withIdentifier: "HomeViewNavigationController")
let TutorialVC = UIStoryboard(name: "Tutorial", bundle: nil).instantiateViewController(withIdentifier: "TutorialViewController")

//@2.
HomeVC.navigationController?.pushViewController(TutorialVC, animated: false);

//@ 3.
self.present(HomeVC, animated: true)

问题是“HomeVC”会先闪烁,然后才会动画“TutorialVC”。

很确定我的结构很糟糕,提前致谢

最佳答案

A navigation controller object manages the currently displayed screens using the navigation stack, which is represented by an array of view controllers

The last view controller in the array is the view controller currently being displayed.

因此,您可以创建 arrayviewcontroller并将其分配给 viewControllers NavigationController的属性(property)

var viewControllers: [UIViewController]

您不需要推送 TutorialVC进入HomeVC

了解更多信息 https://developer.apple.com/documentation/uikit/uinavigationcontroller

关于ios - 如何从另一个导航 Controller 在导航 Controller 中的根 vc 之上呈现 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46108066/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com