-1
我的工作有两个故事板的应用:一为我的应用程序的入职控制器和其他为我的主要应用程序。我的入门视图控制器有一个跳过按钮,当按下时,用户将指示主要故事板。只要用户没有点击跳过按钮,我只想显示入职视图。一旦跳过按钮,相应的故事板应该永久消失。如何永远隐藏Storyboard/ViewControllers?
我以为我可以解决这个问题,只是在应用程序第一次打开时显示入门故事板,我发现一些代码在线,似乎有帮助,但它不工作......这里是代码我的应用程序的的AppDelegate:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
FIRApp.configure()
Fabric.with([Crashlytics.self])
let defaults = NSUserDefaults.standardUserDefaults()
if (defaults.objectForKey("userAsLoggedInBefore") != nil) {
print("Functions")
//here you insert the code to go to the main screen
var mainView: UIStoryboard!
mainView = UIStoryboard(name: "Functions", bundle: nil)
let viewcontroller : UIViewController = mainView.instantiateViewControllerWithIdentifier("functions") as UIViewController
self.window!.rootViewController = viewcontroller
} else {
//this means the user hasn't logged in before and you can redirect him to the onboarding page
print("Onboarding")
var mainView: UIStoryboard!
mainView = UIStoryboard(name: "Main", bundle: nil)
let viewcontroller : UIViewController = mainView.instantiateViewControllerWithIdentifier("onboarding") as UIViewController
self.window!.rootViewController = viewcontroller
}
}
注意,在我的代码“主”是新手上路的故事板,而“功能”是我主要的应用程序代码。
但是这个代码不工作的打算作为我同样的问题依然出现。如果有人可以看看我的代码,看看我是否做错了,那将不胜感激。
在此先感谢!
感谢了很多人! –