简体   繁体   English

在iOS 8的Swift中重用ViewController

[英]Reuse a ViewController in Swift on iOS 8

I have a side menu with different navigation points. 我有一个带有不同导航点的侧面菜单。 The first point is the Home nav. 第一点是家庭导航。 This should send the user back to the main view. 这应将用户送回到主视图。

If I start the app, the main view will be generated by the storyboard. 如果我启动该应用程序,则主视图将由情节提要生成。 Now if a user taps on "Home", I would like to reuse this instance. 现在,如果用户点击“主页”,我想重用该实例。 Is this possible? 这可能吗? (With Swift) (使用Swift)

Thanks 谢谢

You can instantiate a view from a storyboard like so: 您可以像这样通过情节提要实例化视图:

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let homeViewController = storyboard.instantiateViewControllerWithIdentifier("Home")

Then do as you will :) 然后尽你所能:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM