【发布时间】:2018-01-25 16:20:02
【问题描述】:
我试图在启动时在第一个视图控制器之上呈现第二个视图控制器,而不关闭第一个。这个帖子Swift 3 - loading multiple ViewControllers at launch 看起来肯定有答案。建议:
添加你的主视图控制器
var secondViewController:UIViewController!
在你看来DidLoad:
secondViewController: UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "yourIdentifier") as! SecondViewController
就是这样。当你想展示它时,使用:
self.present(secondViewController, animated: true, completion: nil)
例如,如果我将它作为一个动作附加到按钮上,这第三行就非常有用。但是,如果它在第一个 viewController 的 viewDidLoad: 中则不起作用。这就是我需要的。
如何在启动时将第二个 viewController 自动呈现在第一个 viewController 之上?
【问题讨论】:
标签: ios swift uiviewcontroller swift4