0

I have a navigation view controller set up, with a back button, to switch between 2 controllers. A user can either click the back button or just swipe on the screen to get the same behavior. What I'm trying to do is avoid a user that starts a left swipe, and then cancels the transition, staying on the same controller instead of going back to the first.

I know there is a way to block this transition, but this isn't recommended. What I am trying to do is have the transition instantly performed. I've seen on some apps where a user starts the left swipe, the swipe is immediately performed, and doesn't give them the option to cancel their transition halfway through. How do I perform this forced instant transition?

I'm assuming it has something to do with calling the interactivePopGestureRecognizer, but don't know what to do with it.

Thanks!

Adam S.
  • 173
  • 3
  • 15

1 Answers1

0

I figured out a way to do this. In viewDidDisappear, I added the following:

navigationController?.popViewController(animated: true)

If someone starts a swipe from the left, viewDidDisappear gets called. Even if he cancels the transition, the controller will still be popped forcing a return to the root controller.

Adam S.
  • 173
  • 3
  • 15