FROM: http://blog.csdn.net/tianmaxingkong_/article/details/50708511
There are two ways of interface jumping in iOS development, jumping up and down and jumping left and right.
Jump up and down _TO:
let secondViewController = SecondViewController() self.presentViewController(secondViewController, animated: true, completion: nil)
You can also directly self.present();
Jump up and down _BACK:
dismissViewControllerAnimated(true, completion: nil)You can also directly self.dismiss()
-----------------------------------------------
-----------------------------------------------
Jump left and right_TO:
(Push the new view controller into the navigationController, which is equivalent to the push operation)
let secondViewController = SecondViewController() self.navigationController!.pushViewController(secondViewController, animated: true)
Jump left and right _BACK:
(removes the current view controller from the navigation view controller stack, thus returning to the previous interface)
(-) BACK_ to the previous level:
let firstViewController = FirstViewController() self.navigationController?.popViewControllerAnimated(true)
(-) BACK_SPECIFY INTERFACE:
// Get a view controller in the view controller let viewController = self.navigationController?.viewControllers[0] self.navigationController?.popToViewController(viewController as! UIViewController, animated: true)
(-) BACK_ROOT VIEW:
self.navigationController?.popToRootViewControllerAnimated(true)
The settings of the root view need to be set in AppDelegate:
var window: UIWindow? func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { var firstViewController = FirstViewController () var rootNavigationViewController = UINavigationController(rootViewController: firstViewController) self.window!.rootViewController = rootNavigationViewController return true }