在進行iOS開發(fā)時却汉,和之前使用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
}