//添加一个BaseNavigation,可以从不同界面跳转到同一个界面,同一个界面的回退方式:
self.dismissViewControllerAnimated(true, completion:nil)
import Foundation
import UIKit
@objc
class BaseNavigationController: UINavigationController {
var childCtr: UIViewController?
override func viewDidLoad() {
self.navigationBar.hidden =true
if let ctr =childCtr {
self.addChildViewController(ctr)
}
}
override func popViewControllerAnimated(animated: Bool) -> UIViewController? {
ifself.childViewControllers.count ==1 {
dismissViewControllerAnimated(true, completion:nil)
return nil
}else {
returnsuper.popViewControllerAnimated(animated)
}
}
func addBasicChildViewController(ctr: UIViewController) {
self.childCtr = ctr
}
}
//顶部状态栏的颜色
import Foundation
import UIKit
class BaseLightNavigationController: BaseNavigationController {
override func preferredStatusBarStyle() -> UIStatusBarStyle {
returnUIStatusBarStyle.LightContent
}
}
//animated:时候开启动画效果
let ctr = UIStoryboard(name:"LogIn_6p", bundle:nil).instantiateViewControllerWithIdentifier("loginMyselfNavigationController_6p")as!UINavigationController
let navController = BaseLightNavigationController()
navController.childCtr = ctr
self.presentViewController(navController, animated:true, completion:nil)
//pushViewController跳转方式禁用,presentViewController跳转方式是新开一个栈,对应返回是
self.navigationController?.dismissViewControllerAnimated(true, completion: nil)
,showViewController在已有的栈上跳转,对应的返回是
返回根页面vc用 :
1
|
[self.navigationController popToRootViewController]
|
返回指定的某个vc用下面(通过index定位)
1
|
[self.navigationController popToViewController:[self.navigationController.viewControllers objec
|