gpt4 book ai didi

swift - PageViewController(应用程序演示)用于首次启动,然后是 tabBarViewController、Swift

转载 作者:行者123 更新时间:2023-11-30 13:43:53 25 4
gpt4 key购买 nike


我有一个带有 3 个 View 的 PageViewController 来展示应用程序,在最后一页上,我有一个与我的 TabBarViewController 链接的按钮。
我只想在第一次启动时有 3 个演示 View ,然后在下次启动时直接从我的 TabBarViewController 开始。

我该怎么做?
谢谢!!!

最佳答案

编辑

tabBarController:

 required init(coder aDecoder: NSCoder)
{
super.init(coder: aDecoder)!
}

页面 View 和 tabBar 之间的按钮:

@IBAction func firstTime() {

NSUserDefaults.standardUserDefaults().setBool(true, forKey: "hasAppBeenLaunchedBefore")
print(true)

}

应用程序委托(delegate):

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

// Override point for customization after application launch.

didFinishLaunchingOnce()


return true
}

func didFinishLaunchingOnce() -> Bool
{
let defaults = NSUserDefaults.standardUserDefaults()

if let hasBeenLauncherBefore = defaults.stringForKey("hasAppBeenLaunchedBefore")
{
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
var exampleViewController: TabBarViewController = mainStoryboard.instantiateViewControllerWithIdentifier("TabBarViewController") as! TabBarViewController

self.window?.rootViewController = exampleViewController

self.window?.makeKeyAndVisible()
//print(" N-th time app launched ")
return true
}
else
{
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
var exampleViewController: OnboardingPager = mainStoryboard.instantiateViewControllerWithIdentifier("OnboardingPager") as! OnboardingPager

self.window?.rootViewController = exampleViewController

self.window?.makeKeyAndVisible()
//print(" First time app launched ")
defaults.setBool(true, forKey: "hasAppBeenLaunchedBefore")
return false
}
}

享受

关于swift - PageViewController(应用程序演示)用于首次启动,然后是 tabBarViewController、Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35210149/

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