Working With .xib Files
Loading a view controller as the initial view controller.
In the didFinishLaunchingWithOptions
method in the AppDelegate
,
let viewController = ViewController(nibName: "ViewController", bundle: nil)
self.window!.rootViewController = viewController
Embed the app in a UINavigationViewController
.
In the didFinishLaunchingWithOptions
method in the AppDelegate
,
let viewController = ViewController(nibName: "ViewController", bundle: nil)
let navController = UINavigationController(rootViewController: viewController)
self.window!.rootViewController = navController
Modally present a view controller.
let modalViewController = ModalViewController(nibName: "ModalViewController", bundle: nil)
presentViewController(modalViewController, animated: true, completion: nil)
Modally present a view controller embedded inside a UINavigationViewController
.
let modalViewController = ModalViewController(nibName: "ModalViewController", bundle: nil)
let navController = UINavigationController(rootViewController: modalViewController)
presentViewController(navController, animated: true, completion: nil)
Push to a view controller.
let viewController = ViewController(nibName: "ViewController", bundle: nil)
let navController = UINavigationController(rootViewController: viewController)
navigationController?.pushViewController(viewController, animated: true)
Written by Isuru Nanayakkara
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#View
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#