swift 以编程方式设置初始控制器

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了swift 以编程方式设置初始控制器相关的知识,希望对你有一定的参考价值。

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

以上是关于swift 以编程方式设置初始控制器的主要内容,如果未能解决你的问题,请参考以下文章

使用自定义初始化程序 swift 以编程方式实例化和推送视图控制器

在 Swift 中以编程方式设置根视图控制器

尝试在 Swift 中以编程方式设置 rightBarButton

为啥我们不能在以编程方式设置初始视图控制器时以编程方式在视图控制器之间跳转?

Swift iOS以编程方式在导航栏下方设置scrollView约束

目标 c:iOS 13+ 以编程方式设置初始根视图控制器