Search code examples
iossegueviewcontrollernavigationview

ViewController going to previous ViewController by swapping on the screen


Say I have two viewController, AViewController and BViewController. AViewController is Embedded in NavigationController (From menu "Editor > Embedded In > NavigationController"). And from a button action in AViewController it push user to the BViewController (Using segue). Now user can come back to the AViewController by press backButton in BViewController.

But the strange thing is, in BViewController, If I swap the screen from left to right, it seems like removing the view from the stack and showing AViewController. I don't want this swap. I want to use only back button to go previous viewController which is BViewController in this case. How can I stop this swap?

Thanks in advance.

PS : I don't have any type of gesture added in the entire project

enter image description here

enter image description here


Solution

  • In AViewController add in ViewDidLoad the line below to disable interactive pop for navigation controller. Then everything should be like you want.

    self.navigationController.interactivePopGestureRecognizer.enabled = NO;