将UIViewController从一个presentingViewController移到另一个没有动画的

时间:2019-02-24 09:47:50

标签: ios swift uiviewcontroller uikit

我正在尝试将一个视图控制器不带动画地移动到另一个:

viewController.dismiss(animated: false, completion: nil)
// viewController.presentingViewController != nil here
tabBarController.present(viewController, animated: false, completion: nil)

运行此代码时,我崩溃了:Application tried to present modally an active controller

1 个答案:

答案 0 :(得分:1)

您可以将当前零件放入dismiss调用的完成处理程序中

viewController.dismiss(animated: false) {
    tabBarController.present(viewController, animated: false, completion: nil)
}