From 459a4a1e9f1636f98e3145868b9dd2d799cb29ab Mon Sep 17 00:00:00 2001 From: jonkykong Date: Thu, 12 Jan 2017 14:13:43 -0800 Subject: [PATCH 1/4] Second fix for multiple gestures actuating and causing problem. --- Pod/Classes/SideMenuTransition.swift | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/Pod/Classes/SideMenuTransition.swift b/Pod/Classes/SideMenuTransition.swift index 6b6ab09..a90529d 100644 --- a/Pod/Classes/SideMenuTransition.swift +++ b/Pod/Classes/SideMenuTransition.swift @@ -321,6 +321,9 @@ open class SideMenuTransition: UIPercentDrivenInteractiveTransition, UIViewContr // get reference to our fromView, toView and the container view that we should perform the transition in let container = transitionContext.containerView + // prevent any other menu gestures from firing + container.isUserInteractionEnabled = false + if let menuBackgroundColor = SideMenuManager.menuAnimationBackgroundColor { container.backgroundColor = menuBackgroundColor } @@ -371,16 +374,6 @@ open class SideMenuTransition: UIPercentDrivenInteractiveTransition, UIViewContr SideMenuTransition.hideMenuStart() } - let enableTapViewGestures = { (enable: Bool) in - guard let gestures = SideMenuTransition.tapView?.gestureRecognizers else { - return - } - - for gesture in gestures { - gesture.isEnabled = enable - } - } - // perform the animation! let duration = transitionDuration(using: transitionContext) let options: UIViewAnimationOptions = interactive ? .curveLinear : UIViewAnimationOptions() @@ -390,10 +383,10 @@ open class SideMenuTransition: UIPercentDrivenInteractiveTransition, UIViewContr } else { SideMenuTransition.hideMenuStart() } - menuView.isUserInteractionEnabled = false - enableTapViewGestures(false) }) { (finished) -> Void in + container.isUserInteractionEnabled = true + // tell our transitionContext object that we've finished animating if transitionContext.transitionWasCancelled { let viewControllerForPresentedMenu = SideMenuTransition.viewControllerForPresentedMenu @@ -403,8 +396,6 @@ open class SideMenuTransition: UIPercentDrivenInteractiveTransition, UIViewContr } else { SideMenuTransition.presentMenuComplete() } - menuView.isUserInteractionEnabled = true - enableTapViewGestures(true) transitionContext.completeTransition(false) @@ -418,8 +409,6 @@ open class SideMenuTransition: UIPercentDrivenInteractiveTransition, UIViewContr if self.presenting { SideMenuTransition.presentMenuComplete() - menuView.isUserInteractionEnabled = true - enableTapViewGestures(true) transitionContext.completeTransition(true) switch SideMenuManager.menuPresentMode { case .viewSlideOut, .viewSlideInOut: From 4b92f5a776973876c285eb6b84a2160b9083ccb4 Mon Sep 17 00:00:00 2001 From: jonkykong Date: Thu, 12 Jan 2017 14:14:05 -0800 Subject: [PATCH 2/4] Refactoring. --- Pod/Classes/SideMenuTransition.swift | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/Pod/Classes/SideMenuTransition.swift b/Pod/Classes/SideMenuTransition.swift index a90529d..0c3801a 100644 --- a/Pod/Classes/SideMenuTransition.swift +++ b/Pod/Classes/SideMenuTransition.swift @@ -328,25 +328,19 @@ open class SideMenuTransition: UIPercentDrivenInteractiveTransition, UIViewContr container.backgroundColor = menuBackgroundColor } - // create a tuple of our screens - let screens : (from:UIViewController, to:UIViewController) = (transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from)!, transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)!) + let fromViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from)! + let toViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)! // assign references to our menu view controller and the 'bottom' view controller from the tuple // remember that our menuViewController will alternate between the from and to view controller depending if we're presenting or dismissing - let menuViewController = (!presenting ? screens.from : screens.to) - let topViewController = !presenting ? screens.to : screens.from + let menuViewController = presenting ? toViewController : fromViewController + let topViewController = presenting ? fromViewController : toViewController let menuView = menuViewController.view! let topView = topViewController.view! // prepare menu items to slide in if presenting { - var tapView: UIView? - if !SideMenuManager.menuPresentingViewControllerUserInteractionEnabled { - tapView = UIView() - SideMenuTransition.tapView = tapView - } - SideMenuTransition.originalSuperview = topView.superview // add the both views to our view controller @@ -354,17 +348,11 @@ open class SideMenuTransition: UIPercentDrivenInteractiveTransition, UIViewContr case .viewSlideOut, .viewSlideInOut: container.addSubview(menuView) container.addSubview(topView) - if let tapView = tapView { - topView.addSubview(tapView) - } case .menuSlideIn, .menuDissolveIn: container.addSubview(topView) - if let tapView = tapView { - container.addSubview(tapView) - } container.addSubview(menuView) } - + if SideMenuManager.menuFadeStatusBar { let statusBarView = UIView() SideMenuTransition.statusBarView = statusBarView @@ -409,6 +397,12 @@ open class SideMenuTransition: UIPercentDrivenInteractiveTransition, UIViewContr if self.presenting { SideMenuTransition.presentMenuComplete() + if !SideMenuManager.menuPresentingViewControllerUserInteractionEnabled { + let tapView = UIView() + topView.addSubview(tapView) + tapView.frame = topView.bounds + SideMenuTransition.tapView = tapView + } transitionContext.completeTransition(true) switch SideMenuManager.menuPresentMode { case .viewSlideOut, .viewSlideInOut: From 99456afaed94cc20735dd68fa1febd38093418fd Mon Sep 17 00:00:00 2001 From: jonkykong Date: Thu, 12 Jan 2017 14:16:49 -0800 Subject: [PATCH 3/4] Update pod spec. --- SideMenu.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SideMenu.podspec b/SideMenu.podspec index 26dc714..0134fea 100644 --- a/SideMenu.podspec +++ b/SideMenu.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = "SideMenu" - s.version = "2.1.4" + s.version = "2.1.5" s.summary = "Simple side menu control for iOS in Swift inspired by Facebook. Right and Left sides. No coding required." # This description is used to generate tags and improve search results. From a1716035c3fb93ae29ae062a3631c3e82dae348d Mon Sep 17 00:00:00 2001 From: jonkykong Date: Thu, 12 Jan 2017 14:17:04 -0800 Subject: [PATCH 4/4] Update README for Cocoapods. --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index a502324..191f98a 100644 --- a/README.md +++ b/README.md @@ -4,19 +4,19 @@ [![License](https://img.shields.io/cocoapods/l/SideMenu.svg?style=flat)](http://cocoapods.org/pods/SideMenu) [![Platform](https://img.shields.io/cocoapods/p/SideMenu.svg?style=flat)](http://cocoapods.org/pods/SideMenu) -### If you like SideMenu, give it a ★ at the top right of this page. +### If you like SideMenu, give it a ★ at the top right of its [GitHub](https://github.com/jonkykong/SideMenu) page. My name is Jon Kent and I'm a freelance iOS designer, developer, and mobile strategist. I love coffee and play the drums. [**Hire me**](mailto:contact@jonkent.me?subject=Let's build something amazing.) to help you make cool stuff. I also have a [website](http://jonkent.me). *Note: If you're having a problem with SideMenu, please open an [issue](https://github.com/jonkykong/SideMenu/issues/new) and do not email me.* ## Overview SideMenu is a simple and versatile side menu control written in Swift. -- [x] **It can be implemented in storyboard without a single line of [code](#code-less-storyboard-implementation).** -- [x] Four standard animation styles to choose from (even parallax if you want to get weird). -- [x] Highly customizable without needing to write tons of custom code. -- [x] Supports continuous swiping between side menus on boths sides in a single gesture. -- [x] Global menu configuration. Set-up once and be done for all screens. -- [x] Menus can be presented and dismissed the same as any other View Controller since this control uses custom transitions. +* **It can be implemented in storyboard without a single line of [code](#code-less-storyboard-implementation).** +* Four standard animation styles to choose from (even parallax if you want to get weird). +* Highly customizable without needing to write tons of custom code. +* Supports continuous swiping between side menus on boths sides in a single gesture. +* Global menu configuration. Set-up once and be done for all screens. +* Menus can be presented and dismissed the same as any other View Controller since this control uses custom transitions. Check out the example project to see it in action! @@ -26,7 +26,7 @@ Check out the example project to see it in action! ![](etc/InOut.gif) ## Requirements -- [x] iOS 8 or higher +* iOS 8 or higher ## Installation ### CocoaPods