iosxcodeuinavigationcontrolleruitabbarcontrollersegue

Disable back navigation for single ViewController


I have the following VCs:

Interface Builder

VC in the center is "Login" screen, it just redirects user to the tab bar controller, if user is authorized.

I want to disable going back to Login VC from any VC within TabBarController (with "back" button and swipe).

How to achieve this?


Solution

  • for disabling both back button and swipe back feature add this lines to your viewDidLoad method:

    self.navigationItem.leftBarButtonItem = nil;
    self.navigationItem.hidesBackButton = true;
    self.navigationController?.navigationItem.backBarButtonItem?.isEnabled = false;
    self.navigationController?.interactivePopGestureRecognizer?.isEnabled = false;