回答

0

编辑

tabBarController:

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

页面访问量和TabBar之间按钮:

@IBAction func firstTime() { 

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

} 

的AppDelegate:

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 
    } 
} 

享受