本文介绍了如何使用Swift,iOS 7设置rootViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在app delegate中设置rootViewController ..

  func application(application:UIApplication,didFinishLaunchingWithOptions launchOptions:NSDictionary ?) - > Bool {

var rootView:MyRootViewController = MyRootViewController()
//将viewController设置为根视图的代码??


返回true

}


  func application(application:UIApplication, didFinishLaunchingWithOptions launchOptions:NSDictionary?) - > Bool {

var rootView:MyRootViewController = MyRootViewController()

if let window = self.window {
window.rootViewController = rootView
}

返回true
}


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

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {

     var rootView: MyRootViewController = MyRootViewController()
     //Code to set this viewController as the root view??


     return true

}
解决方案

You can do something like this.

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {

     var rootView: MyRootViewController = MyRootViewController()

     if let window = self.window{
            window.rootViewController = rootView
     }

     return true
}

这篇关于如何使用Swift,iOS 7设置rootViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 20:03