48932

How to turn off the automatic swipe to go back in navigation controller? Swift

Question:

I need to turn off the automatic gesture swiping to go back in navigation controller. I using Swift.

I have already searched but didn't found a solution for me.

Answer1:

You can disable the interactivePopGestureRecognizer of your navigationController:

self.navigationController?.interactivePopGestureRecognizer.enabled = false

Answer2:

self.navigationController.interactivePopGestureRecognizer.delegate = self func gestureRecognizerShouldBegin(gestureRecognizer: UIGestureRecognizer!) -> Bool { return false; }

I found this after a couple little searches. Not sure if its correct or not.

Answer3:

Swift version: Add this delegate in your UIViewController: UIGestureRecognizerDelegate

Then in your viewDidLoad() method add the next line:

self.navigationController!.interactivePopGestureRecognizer.delegate = self

and finally add this delegate method:

func gestureRecognizerShouldBegin(gestureRecognizer: UIGestureRecognizer) -> Bool { return false }

Good luck!

Recommend

  • pushed view should appear with transparent background
  • Unable to pushViewController iOS
  • CATransition white flash in background?
  • unrecognized selector sent to instance error when a button is clicked
  • Xamarin IOS hide bar back button
  • Xamarin Forms Disposed Textview
  • ARC delegate memory management
  • CAShapeLayer’s strokeEnd doesn’t animate
  • jQuery UI Tabs force delay before changing tab on mouseover
  • C# - automatic delegate type from method
  • How to wait till webViewDidFinishLoad gets completed
  • YQL finance gets null in results
  • Multiple storyboards: should I use a singleton pattern to cache them?
  • Convert Func to Func
  • Simple Injector fails if using verify before setting dependency resolver for MVC 4
  • How to make a UserDetailsManager available as a bean
  • “[CALayer release]: message sent to deallocated instance” when dismissing modal view controller
  • UIImagePickerControllerDelegate Methods Not Called When Delegate Not UIViewController
  • WPF Run Animation in a separate Thread
  • How to fallback to entirely different index page if user has javascript disable?
  • How to get google-services.json from Developer console?
  • How to make the tableview response pan gesture in ZUUIRevealController
  • How to check disabled jobs with Jenkins server?
  • How to protect an asp:textbox from user input?
  • CRASH: *** -[__NSArrayM objectAtIndex:]: index 4294967295 beyond bounds [0 .. 9]
  • retrieving data from url in iphone
  • Opaque reference instead of PImpl. Is it possible?
  • Build Successful but not running on simulator
  • how to save the state in userdefaults of accessory checkmark-iphone
  • MonoTouch: How to download pdf incrementally as indicated in the Apple slides “Building Newsstand Ap
  • Can Jackson SerializationFeature be overridden per field or class?
  • How to model a transition system with SPIN
  • Getting 'uninitialized constant' error when using delegate in belongs_to in model
  • Suggestions to manage Login/Logout transitions
  • Cant find why the layout is getting smaller
  • How to stop GridView from loading again when I press back button?
  • Bitwise OR returns boolean when one of operands is nil
  • sending mail using smtp is too slow
  • costura.fody for a dll that references another dll
  • Binding checkboxes to object values in AngularJs