In my UINavigationController
I added custom back buttons with the side effect that it is not possible anymore to swipe left to right to pop the view controller and
Implement UINavigationControllerDelegate
for your navigation controller and enable/disable the gesture recognizer there.
// Fix bug when pop gesture is enabled for the root controller
func navigationController(navigationController: UINavigationController, didShowViewController viewController: UIViewController, animated: Bool) {
self.interactivePopGestureRecognizer?.enabled = self.viewControllers.count > 1
}
Keeping the code independent from the pushed view controllers.