diff --git a/Pod/Classes/SideMenuAnimationController.swift b/Pod/Classes/SideMenuAnimationController.swift index aa6ff8d3..0edc29b4 100644 --- a/Pod/Classes/SideMenuAnimationController.swift +++ b/Pod/Classes/SideMenuAnimationController.swift @@ -35,7 +35,7 @@ internal final class SideMenuAnimationController: NSObject, UIViewControllerAnim private weak var containerView: UIView? private let leftSide: Bool private weak var originalSuperview: UIView? - private var presentationController: SideMenuPresentationController? + private var presentationController: SideMenuPresentationController! private unowned var presentedViewController: UIViewController? private unowned var presentingViewController: UIViewController? weak var delegate: SideMenuAnimationControllerDelegate? @@ -104,6 +104,7 @@ internal final class SideMenuAnimationController: NSObject, UIViewControllerAnim } func layout() { + guard presentationController != nil else { fatalError("presentationController not initialized") } presentationController?.containerViewWillLayoutSubviews() } } @@ -128,28 +129,32 @@ private extension SideMenuAnimationController { } func transitionWillBegin(presenting: Bool) { + guard presentationController != nil else { fatalError("presentationController not initialized") } + // prevent any other menu gestures from firing containerView?.isUserInteractionEnabled = false if presenting { - presentationController?.presentationTransitionWillBegin() + presentationController.presentationTransitionWillBegin() } else { - presentationController?.dismissalTransitionWillBegin() + presentationController.dismissalTransitionWillBegin() } } func transition(presenting: Bool) { + guard presentationController != nil else { fatalError("presentationController not initialized") } if presenting { - presentationController?.presentationTransition() + presentationController.presentationTransition() } else { - presentationController?.dismissalTransition() + presentationController.dismissalTransition() } } func transitionDidEnd(presenting: Bool, completed: Bool) { + guard presentationController != nil else { fatalError("presentationController not initialized") } if presenting { - presentationController?.presentationTransitionDidEnd(completed) + presentationController.presentationTransitionDidEnd(completed) } else { - presentationController?.dismissalTransitionDidEnd(completed) + presentationController.dismissalTransitionDidEnd(completed) } containerView?.isUserInteractionEnabled = true } diff --git a/Pod/Classes/SideMenuNavigationController.swift b/Pod/Classes/SideMenuNavigationController.swift index d88bb8b6..6957a484 100644 --- a/Pod/Classes/SideMenuNavigationController.swift +++ b/Pod/Classes/SideMenuNavigationController.swift @@ -265,7 +265,9 @@ open class SideMenuNavigationController: UINavigationController { super.viewWillTransition(to: size, with: coordinator) // Don't bother resizing if the view isn't visible - guard let transitionController = transitionController, !view.isHidden else { return } + guard let transitionController = transitionController, !view.isHidden, + UIApplication.shared.applicationState != UIApplication.State.background, + UIApplication.shared.applicationState != UIApplication.State.inactive else { return } rotating = true