在进行iOS开发时,和之前使用OC一样,默认使用storyboard,所以无需在AppDelegate中进行任何操作(push除外)。
不使用storyboard的纯代码需要增加如下代码:(文中代码为swift3.0)
- 非navigationController
var window: UIWindow?
var viewController: UIViewController?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
self.window = UIWindow.init(frame: UIScreen.main.bounds)
let vc = ViewController()
self.viewController = vc
self.window?.rootViewController = self.viewController
self.window?.makeKeyAndVisible()
return true
}
- navigationController
var window: UIWindow?
var viewController: UINavigationController?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
self.window = UIWindow.init(frame: UIScreen.main.bounds)
let vc = ViewController()
self.viewController = UINavigationController.init(rootViewController: vc)
self.window?.rootViewController = self.viewController
self.window?.makeKeyAndVisible()
return true
}
网友评论