From 5b4b6afdbef49fbd985d108d19371ef333d2c285 Mon Sep 17 00:00:00 2001 From: andrei Date: Wed, 4 Jan 2017 18:34:20 +0900 Subject: [PATCH] adding possibility of tab bar or nav bar --- Pod/Classes/UISideMenuNavigationController.swift | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Pod/Classes/UISideMenuNavigationController.swift b/Pod/Classes/UISideMenuNavigationController.swift index ac6f352..50570da 100644 --- a/Pod/Classes/UISideMenuNavigationController.swift +++ b/Pod/Classes/UISideMenuNavigationController.swift @@ -125,11 +125,16 @@ open class UISideMenuNavigationController: UINavigationController { super.pushViewController(viewController, animated: animated) return } - - guard let presentingViewController = (presentingViewController as? UITabBarController)?.selectedViewController as? UINavigationController else { + + var presentingViewControllerOptional = self.presentingViewController as? UINavigationController + if presentingViewControllerOptional == nil { + presentingViewControllerOptional = (self.presentingViewController as? UITabBarController)?.selectedViewController as? UINavigationController + } else { print("SideMenu Warning: attempt to push a View Controller from \(self.presentingViewController.self) where its navigationController == nil. It must be embedded in a Navigation Controller for this to work.") return } + + let presentingViewController = presentingViewControllerOptional! // to avoid overlapping dismiss & pop/push calls, create a transaction block where the menu // is dismissed after showing the appropriate screen