How to set the rootViewController with Swift, iOS 7

后端 未结 5 2169
暗喜
暗喜 2020-12-05 17:59

I want to set the rootViewController in the app delegate ..

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDicti         


        
5条回答
  •  清歌不尽
    2020-12-05 18:17

    Swift 2.0:

    var window: UIWindow?
     var storyboard:UIStoryboard?
    
     func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    
      window =  UIWindow(frame: UIScreen.mainScreen().bounds)
      window?.makeKeyAndVisible()
    
      storyboard = UIStoryboard(name: "Main", bundle: nil)
      let rootController = storyboard!.instantiateViewControllerWithIdentifier("secondVCID")
    
      if let window = self.window {
       window.rootViewController = rootController
      }
    

提交回复
热议问题