override init(rootViewController: UIViewController) {
super.init(rootViewController: rootViewController)
self.interactivePopGestureRecognizer?.delegate = self as? UIGestureRecognizerDelegate
self.delegate = self as UINavigationControllerDelegate
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
extension NavigationController: UINavigationControllerDelegate {
func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {
}
func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) {
if navigationController.viewControllers.count > 1 {
self.interactivePopGestureRecognizer?.isEnabled = true
}else {
self.interactivePopGestureRecognizer?.isEnabled = false
}
}
}