IOS開發(fā)中界面跳轉(zhuǎn)有兩種方式,上下跳轉(zhuǎn)和左右跳轉(zhuǎn)。
上下跳轉(zhuǎn)_TO:
let secondViewController = SecondViewController()
self.presentViewController(secondViewController, animated:true, completion:nil)
上下跳轉(zhuǎn)_BACK:
dismissViewControllerAnimated(true, completion:nil)
-----------------------------------------------
-----------------------------------------------
左右跳轉(zhuǎn)_TO:
(將新的視圖控制器PUSH到navigationController中,相當于入棧操作)
let secondViewController = SecondViewController()
self.navigationController!.pushViewController(secondViewController, animated:true)
左右跳轉(zhuǎn)_BACK:
(將當前視圖控制器從導(dǎo)航視圖控制器堆棧中移除,從而返回到了上一級界面)
( - ) BACK_到上一級:
let firstViewController = FirstViewController()
self.navigationController?.popViewControllerAnimated(true)
( - )?BACK_指定界面:
// 獲得視圖控制器中的某一視圖控制器
let viewController =self.navigationController?.viewControllers[0]
self.navigationController?.popToViewController(viewController as!UIViewController, animated:true)
( - )?BACK_根視圖:
self.navigationController?.popToRootViewControllerAnimated(true)
根視圖的設(shè)置需要在AppDelegate中設(shè)置:
var window:UIWindow?
func application(application:UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool
{
? ? var firstViewController = FirstViewController()
var rootNavigationViewController =UINavigationController(rootViewController: firstViewController)
self.window!.rootViewController = rootNavigationViewController
returntrue
}