JGuizard
7/11/2016 - 9:30 AM

Set initial controller programmately

Set initial controller programmately

//APPDELEGATE


   func grabStoryboard() -> UIStoryboard {
        var storyboard = UIStoryboard()
        let height = UIScreen.mainScreen().bounds.size.height
        
    
        if height == 568 {
            storyboard = UIStoryboard(name: "Main", bundle: nil)
        } else {
            storyboard = UIStoryboard(name: "4-7inch", bundle: nil)
        }
        
        
        NSLog("Height: "+String(height))
        
        return storyboard
    }


    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Override point for customization after application launch.
        UIApplication.sharedApplication().setStatusBarStyle(UIStatusBarStyle.LightContent, animated: true)
        IQKeyboardManager.sharedManager().enable = true
        let storyboard: UIStoryboard = self.grabStoryboard()
        
        if(Profile.instance.isSigned())
        {
            self.window?.rootViewController = storyboard.instantiateInitialViewController()! as UIViewController
        }
        else
        {
            self.window?.rootViewController = storyboard.instantiateViewControllerWithIdentifier("LoginController") as! UIViewController

        }
            self.window?.makeKeyAndVisible()
        
        let barAppearace = UIBarButtonItem.appearance()
        barAppearace.setBackButtonTitlePositionAdjustment(UIOffsetMake(0, -60), forBarMetrics:UIBarMetrics.Default)
        
        return true
    }