我正在尝试使用从右滑动的动画来更改rootViewController。
我知道如何使用翻转动画:
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let viewController = mainStoryboard.instantiateViewControllerWithIdentifier("LandingViewController")
UIView.transitionWithView( UIApplication.sharedApplication().keyWindow!,
duration: 0.5,
options: UIViewAnimationOptions.TransitionFlipFromLeft,
animations: { UIApplication.sharedApplication().keyWindow?.rootViewController = viewController; },
completion: nil)
试试这个
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let viewController = mainStoryboard.instantiateViewControllerWithIdentifier("LandingViewController")
let navigationController = UIApplication.sharedApplication().keyWindow?.rootViewController.navigationController
//first push the viewController
navigationController?.pushViewController(viewController, animated: true)
viewController
的viewDidAppear处,您应该执行此代码//remove all previous controllers in the stack by settings viewControllers stack with only current viewController
self.navigationController?.viewControllers = [self]
关于ios - 更改rootViewController时从正确的动画滑动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39133255/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |