From 7541ac0ef768cc766faaa56b91b851c0447de9f8 Mon Sep 17 00:00:00 2001 From: jonkykong Date: Thu, 21 Jan 2016 21:11:46 -0800 Subject: [PATCH] Fix for rare crash when app is backgrounded. --- Example/Podfile.lock | 4 ++-- Example/Pods/Local Podspecs/SideMenu.podspec.json | 4 ++-- Example/Pods/Manifest.lock | 4 ++-- Example/Pods/Target Support Files/SideMenu/Info.plist | 2 +- Pod/Classes/SideMenuTransition.swift | 10 ++++++---- SideMenu.podspec | 2 +- 6 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Example/Podfile.lock b/Example/Podfile.lock index 36003e8..6126618 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -1,5 +1,5 @@ PODS: - - SideMenu (1.0.0) + - SideMenu (1.0.2) DEPENDENCIES: - SideMenu (from `../`) @@ -9,6 +9,6 @@ EXTERNAL SOURCES: :path: ../ SPEC CHECKSUMS: - SideMenu: 97ed15625c7b86c4090c2e931a3e5ee89f050afa + SideMenu: 190288fb750f9a2ca53bdd017374e520843f612f COCOAPODS: 0.39.0 diff --git a/Example/Pods/Local Podspecs/SideMenu.podspec.json b/Example/Pods/Local Podspecs/SideMenu.podspec.json index 50092b1..b07f066 100644 --- a/Example/Pods/Local Podspecs/SideMenu.podspec.json +++ b/Example/Pods/Local Podspecs/SideMenu.podspec.json @@ -1,6 +1,6 @@ { "name": "SideMenu", - "version": "1.0.0", + "version": "1.0.2", "summary": "Simple side menu control in Swift inspired by Facebook. Right and Left sides. No coding required.", "description": "SideMenu is a simple and versatile side menu control. It's highly customizable, but can also be implemented in storyboard without a single line of code. The are three standard animation styles to choose from along with several other options for further customization if desired. Just type SideMenuManager.menu... and code completion will show you everything you can customize.", "homepage": "https://github.com/jonkykong/SideMenu", @@ -11,7 +11,7 @@ }, "source": { "git": "https://github.com/jonkykong/SideMenu.git", - "tag": "1.0.0" + "tag": "1.0.2" }, "platforms": { "ios": "8.0" diff --git a/Example/Pods/Manifest.lock b/Example/Pods/Manifest.lock index 36003e8..6126618 100644 --- a/Example/Pods/Manifest.lock +++ b/Example/Pods/Manifest.lock @@ -1,5 +1,5 @@ PODS: - - SideMenu (1.0.0) + - SideMenu (1.0.2) DEPENDENCIES: - SideMenu (from `../`) @@ -9,6 +9,6 @@ EXTERNAL SOURCES: :path: ../ SPEC CHECKSUMS: - SideMenu: 97ed15625c7b86c4090c2e931a3e5ee89f050afa + SideMenu: 190288fb750f9a2ca53bdd017374e520843f612f COCOAPODS: 0.39.0 diff --git a/Example/Pods/Target Support Files/SideMenu/Info.plist b/Example/Pods/Target Support Files/SideMenu/Info.plist index 11db4b7..a7faeb7 100644 --- a/Example/Pods/Target Support Files/SideMenu/Info.plist +++ b/Example/Pods/Target Support Files/SideMenu/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.0.0 + 1.0.2 CFBundleSignature ???? CFBundleVersion diff --git a/Pod/Classes/SideMenuTransition.swift b/Pod/Classes/SideMenuTransition.swift index d13a0f8..c4ef5f8 100644 --- a/Pod/Classes/SideMenuTransition.swift +++ b/Pod/Classes/SideMenuTransition.swift @@ -135,6 +135,8 @@ internal class SideMenuTransition: UIPercentDrivenInteractiveTransition, UIViewC } internal class func hideMenuStart() { + NSNotificationCenter.defaultCenter().removeObserver(SideMenuTransition.singleton) + let mainViewController = SideMenuTransition.viewControllerForPresentedMenu! let menuView = SideMenuTransition.presentDirection == .Left ? SideMenuManager.menuLeftNavigationController!.view : SideMenuManager.menuRightNavigationController!.view menuView.transform = CGAffineTransformIdentity @@ -174,7 +176,6 @@ internal class SideMenuTransition: UIPercentDrivenInteractiveTransition, UIViewC mainViewController.view.motionEffects.removeAll() mainViewController.view.layer.shadowOpacity = 0 menuView.layer.shadowOpacity = 0 - NSNotificationCenter.defaultCenter().removeObserver(self) if let topNavigationController = mainViewController as? UINavigationController { topNavigationController.interactivePopGestureRecognizer!.enabled = true } @@ -217,6 +218,8 @@ internal class SideMenuTransition: UIPercentDrivenInteractiveTransition, UIViewC } internal class func presentMenuComplete() { + NSNotificationCenter.defaultCenter().addObserver(SideMenuTransition.singleton, selector:"applicationDidEnterBackgroundNotification", name: UIApplicationDidEnterBackgroundNotification, object: nil) + let mainViewController = SideMenuTransition.viewControllerForPresentedMenu! switch SideMenuManager.menuPresentMode { case .MenuSlideIn, .MenuDissolveIn: @@ -303,9 +306,6 @@ internal class SideMenuTransition: UIPercentDrivenInteractiveTransition, UIViewC } SideMenuTransition.hideMenuStart() // offstage for interactive - - NSNotificationCenter.defaultCenter().removeObserver(self) - NSNotificationCenter.defaultCenter().addObserver(SideMenuTransition.singleton, selector:"applicationDidEnterBackgroundNotification", name: UIApplicationDidEnterBackgroundNotification, object: nil) } // perform the animation! @@ -326,6 +326,8 @@ internal class SideMenuTransition: UIPercentDrivenInteractiveTransition, UIViewC if transitionContext.transitionWasCancelled() { if self.presenting { SideMenuTransition.hideMenuComplete() + } else { + SideMenuTransition.presentMenuComplete() } transitionContext.completeTransition(false) } else { diff --git a/SideMenu.podspec b/SideMenu.podspec index f571527..5c6597c 100644 --- a/SideMenu.podspec +++ b/SideMenu.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = "SideMenu" - s.version = "1.0.1" + s.version = "1.0.2" s.summary = "Simple side menu control in Swift inspired by Facebook. Right and Left sides. No coding required." # This description is used to generate tags and improve search results.