How to present view controller from right to left in iOS using Swift

前端 未结 12 1215
悲&欢浪女
悲&欢浪女 2020-12-04 06:03

I am using presentViewController to present new screen

let dashboardWorkout = DashboardWorkoutViewController()
presentViewController(dashboardWorkout, anima         


        
12条回答
  •  清歌不尽
    2020-12-04 06:38

    I have a better solution that has worked for me if you want to mantain the classic animation of Apple, without see that "black" transition that you see using CATransition(). Simply use popToViewController method.

    You can look for the viewController you need in

    self.navigationController.viewControllers // Array of VC that contains all VC of current stack
    

    You can look for the viewController you need by searching for it's restorationIdentifier.

    BE CAREFUL: for example, if you are navigating through 3 view controllers, and when arrive to the last you want to pop the first. You will lose, in this case, the refer to the effective SECOND view controller because the popToViewController has overwritten it. BTW, there's a solution: you can easily save before the popToViewcontroller, the VC you will need later. It worked for me very well.

提交回复
热议问题