Swift:如何实现登录情节提要? [英] Swift: How to implement a login storyboard?
本文介绍了Swift:如何实现登录情节提要?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个不同的故事板:
I have two different storyboards:
- 主板:SWrevealViewController(应用程序的主要部分)
- Loginstoryboard:登录/注册控制器
当用户未登录或注销时,应使用Loginstoryboard.然后应该在Mainstoryboard上进行搜索.
The Loginstoryboard should be used when the user is not logged in or the user logged out. Then there should be a segue to the Mainstoryboard.
如何迅速实施?
期待您的回答!
扬
Looking forward to your answers!
Jan
推荐答案
您是否尝试过在application(_:didFinishLaunchingWithOptions:)
假设Mainstoryboard
有您的rootViewController
:
if userIsNotLoggedIn {
let storyboard = UIStoryboard(name: "Loginstoryboard", bundle: nil)
let loginController = storyboard.instantiateViewControllerWithIdentifier("LoginNavigationController") as UINavigationController
window?.rootViewController = loginController
}
要在登录后切换视图控制器,您可以执行以下操作:
To switch view controllers once logged in you can do this:
func loggedIn() {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let mainController = storyboard.instantiateViewControllerWithIdentifier("MainVC") as UIViewController
let appDelegate = UIApplication.sharedApplication().delegate as AppDelegate
appDelegate.window?.rootViewController = mainController
}
这篇关于Swift:如何实现登录情节提要?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文