From 7fb3ec03e919a6d4a5c622f224c2277ace85c61f Mon Sep 17 00:00:00 2001 From: Aryan Ghassemi Date: Wed, 22 Apr 2015 20:25:52 -0700 Subject: [PATCH 1/3] Fixed is landscape issues #138 --- .../Animations/SlideNavigationContorllerAnimatorSlide.m | 2 +- SlideMenu/Source/SlideNavigationController.m | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorSlide.m b/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorSlide.m index c694520..446cf25 100644 --- a/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorSlide.m +++ b/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorSlide.m @@ -122,7 +122,7 @@ { if (UIDeviceOrientationIsLandscape(orientation)) { - rect.origin.y = (orientation == UIDeviceOrientationLandscapeRight) ? location : location*-1; + rect.origin.y = (orientation == UIDeviceOrientationLandscapeRight) ? location*-1 : location; } else { diff --git a/SlideMenu/Source/SlideNavigationController.m b/SlideMenu/Source/SlideNavigationController.m index 2efcdba..f88e05b 100644 --- a/SlideMenu/Source/SlideNavigationController.m +++ b/SlideMenu/Source/SlideNavigationController.m @@ -537,7 +537,7 @@ static SlideNavigationController *singletonInstance; if (UIDeviceOrientationIsLandscape(orientation)) { rect.origin.x = 0; - rect.origin.y = (orientation == UIDeviceOrientationLandscapeRight) ? location : location*-1; + rect.origin.y = (orientation == UIDeviceOrientationLandscapeRight) ? location*-1 : location; } else { @@ -621,8 +621,8 @@ static SlideNavigationController *singletonInstance; if (UIDeviceOrientationIsLandscape(orientation)) { return (orientation == UIDeviceOrientationLandscapeRight) - ? rect.origin.y - : rect.origin.y*-1; + ? rect.origin.y*-1 + : rect.origin.y; } else { From 240684c788f39a88f15ecb0a4af56fcaf58945f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B0=D0=B2=D0=B5=D0=BB=20=D0=9A=D1=80=D1=83=D0=B3?= =?UTF-8?q?=D0=BB=D0=BE=D0=B2?= Date: Tue, 30 Jun 2015 18:18:37 +0300 Subject: [PATCH 2/3] Hook point for swipe menu begin. --- SlideMenu/AppDelegate.m | 5 +++++ SlideMenu/Source/SlideNavigationController.h | 3 +++ SlideMenu/Source/SlideNavigationController.m | 5 ++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/SlideMenu/AppDelegate.m b/SlideMenu/AppDelegate.m index 8e84687..7633851 100644 --- a/SlideMenu/AppDelegate.m +++ b/SlideMenu/AppDelegate.m @@ -42,6 +42,11 @@ NSLog(@"Opened %@", menu); }]; + [[NSNotificationCenter defaultCenter] addObserverForName:SlideNavigationControllerWillOpen object:nil queue:nil usingBlock:^(NSNotification *note) { + NSString *menu = note.userInfo[@"menu"]; + NSLog(@"Opening %@", menu); + }]; + [[NSNotificationCenter defaultCenter] addObserverForName:SlideNavigationControllerDidReveal object:nil queue:nil usingBlock:^(NSNotification *note) { NSString *menu = note.userInfo[@"menu"]; NSLog(@"Revealed %@", menu); diff --git a/SlideMenu/Source/SlideNavigationController.h b/SlideMenu/Source/SlideNavigationController.h index b64701b..b8405c8 100644 --- a/SlideMenu/Source/SlideNavigationController.h +++ b/SlideMenu/Source/SlideNavigationController.h @@ -44,6 +44,7 @@ typedef enum{ @protocol SlideNavigationContorllerAnimator; @interface SlideNavigationController : UINavigationController +extern NSString * const SlideNavigationControllerWillOpen; extern NSString * const SlideNavigationControllerDidOpen; extern NSString *const SlideNavigationControllerDidClose; extern NSString *const SlideNavigationControllerDidReveal; @@ -75,4 +76,6 @@ extern NSString *const SlideNavigationControllerDidReveal; - (void)toggleRightMenu; - (BOOL)isMenuOpen; +- (void)prepareMenuForReveal:(Menu)menu; + @end diff --git a/SlideMenu/Source/SlideNavigationController.m b/SlideMenu/Source/SlideNavigationController.m index f88e05b..e2b1462 100644 --- a/SlideMenu/Source/SlideNavigationController.m +++ b/SlideMenu/Source/SlideNavigationController.m @@ -43,9 +43,10 @@ typedef enum { @implementation SlideNavigationController +NSString * const SlideNavigationControllerWillOpen = @"SlideNavigationControllerWillOpen"; NSString * const SlideNavigationControllerDidOpen = @"SlideNavigationControllerDidOpen"; NSString * const SlideNavigationControllerDidClose = @"SlideNavigationControllerDidClose"; -NSString *const SlideNavigationControllerDidReveal = @"SlideNavigationControllerDidReveal"; +NSString * const SlideNavigationControllerDidReveal = @"SlideNavigationControllerDidReveal"; #define MENU_SLIDE_ANIMATION_DURATION .3 #define MENU_SLIDE_ANIMATION_OPTION UIViewAnimationOptionCurveEaseOut @@ -605,6 +606,8 @@ static SlideNavigationController *singletonInstance; [self updateMenuFrameAndTransformAccordingToOrientation]; [self.menuRevealAnimator prepareMenuForAnimation:menu]; + + [self postNotificationWithName:SlideNavigationControllerWillOpen forMenu:menu]; } - (CGFloat)horizontalLocation From 0da57dfd53757954703ec276e191f381081ba129 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B0=D0=B2=D0=B5=D0=BB=20=D0=9A=D1=80=D1=83=D0=B3?= =?UTF-8?q?=D0=BB=D0=BE=D0=B2?= Date: Wed, 1 Jul 2015 15:58:20 +0300 Subject: [PATCH 3/3] Fixed orientation issues. --- README.md | 7 +--- .../SlideNavigationContorllerAnimatorSlide.m | 22 +++++------ SlideMenu/Source/SlideNavigationController.h | 1 - SlideMenu/Source/SlideNavigationController.m | 39 ++++++++----------- 4 files changed, 29 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index 0fcb091..dbf6452 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ -iOS-Slide-Menu [![Version](http://cocoapod-badges.herokuapp.com/v/iOS-Slide-Menu/badge.png)](http://cocoadocs.org/docsets/iOS-Slide-Menu) +iOS-Slide-Menu --------- - iOS Slide Menu built on top of UINavigationController, with configurable buttons, reveal animations, and tap/swiper gesture recognizers. - [Setup](https://github.com/aryaxt/iOS-Slide-Menu#setup) @@ -12,10 +11,6 @@ iOS Slide Menu built on top of UINavigationController, with configurable buttons ![alt tag](https://raw.github.com/aryaxt/iOS-Slide-Menu/master/slideMenuAnimation.gif) -Version 1.4.5 Notes ---------- -Enabling shouldRecognizeSimultaneouslyWithGestureRecognizer was causing issues, if you are seeing unexpected gesture behavior delete the pod and reinstall as that method has been removed - Version 1.4.0 Notes --------- ```switchToViewController:withCompletion:``` method has been deprecated. In order to get the exact same behavior use ```popToRootAndSwitchToViewController:withCompletion``` diff --git a/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorSlide.m b/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorSlide.m index 446cf25..9e2c0c3 100644 --- a/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorSlide.m +++ b/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorSlide.m @@ -58,7 +58,7 @@ ? [SlideNavigationController sharedInstance].leftMenu : [SlideNavigationController sharedInstance].rightMenu; - UIDeviceOrientation orientation = [UIDevice currentDevice].orientation; + UIInterfaceOrientation orientation= [SlideNavigationController sharedInstance].interfaceOrientation; CGRect rect = menuViewController.view.frame; if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")) @@ -67,9 +67,9 @@ } else { - if (UIDeviceOrientationIsLandscape(orientation)) + if (UIInterfaceOrientationIsLandscape(orientation)) { - if (orientation == UIDeviceOrientationLandscapeRight) + if (orientation == UIInterfaceOrientationLandscapeRight) { rect.origin.y = (menu == MenuLeft) ? self.slideMovement*-1 : self.slideMovement; } @@ -80,7 +80,7 @@ } else { - if (orientation == UIDeviceOrientationPortrait) + if (orientation == UIInterfaceOrientationPortrait) { rect.origin.x = (menu == MenuLeft) ? self.slideMovement*-1 : self.slideMovement; } @@ -100,7 +100,7 @@ ? [SlideNavigationController sharedInstance].leftMenu : [SlideNavigationController sharedInstance].rightMenu; - UIDeviceOrientation orientation = [UIDevice currentDevice].orientation; + UIInterfaceOrientation orientation = [SlideNavigationController sharedInstance].interfaceOrientation; NSInteger location = (menu == MenuLeft) ? (self.slideMovement * -1) + (self.slideMovement * progress) @@ -120,13 +120,13 @@ } else { - if (UIDeviceOrientationIsLandscape(orientation)) + if (UIInterfaceOrientationIsLandscape(orientation)) { - rect.origin.y = (orientation == UIDeviceOrientationLandscapeRight) ? location*-1 : location; + rect.origin.y = (orientation == UIInterfaceOrientationLandscapeRight) ? location : location*-1; } else { - rect.origin.x = (orientation == UIDeviceOrientationPortrait) ? location : location*-1; + rect.origin.x = (orientation == UIInterfaceOrientationPortrait) ? location : location*-1; } } @@ -147,8 +147,8 @@ ? [SlideNavigationController sharedInstance].leftMenu : [SlideNavigationController sharedInstance].rightMenu; - UIDeviceOrientation orientation = [UIDevice currentDevice].orientation; - + UIInterfaceOrientation orientation= [SlideNavigationController sharedInstance].interfaceOrientation; + CGRect rect = menuViewController.view.frame; if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")) @@ -157,7 +157,7 @@ } else { - if (UIDeviceOrientationIsLandscape(orientation)) + if (UIInterfaceOrientationIsLandscape(orientation)) { rect.origin.y = 0; } diff --git a/SlideMenu/Source/SlideNavigationController.h b/SlideMenu/Source/SlideNavigationController.h index b8405c8..feefa80 100644 --- a/SlideMenu/Source/SlideNavigationController.h +++ b/SlideMenu/Source/SlideNavigationController.h @@ -44,7 +44,6 @@ typedef enum{ @protocol SlideNavigationContorllerAnimator; @interface SlideNavigationController : UINavigationController -extern NSString * const SlideNavigationControllerWillOpen; extern NSString * const SlideNavigationControllerDidOpen; extern NSString *const SlideNavigationControllerDidClose; extern NSString *const SlideNavigationControllerDidReveal; diff --git a/SlideMenu/Source/SlideNavigationController.m b/SlideMenu/Source/SlideNavigationController.m index e2b1462..2785286 100644 --- a/SlideMenu/Source/SlideNavigationController.m +++ b/SlideMenu/Source/SlideNavigationController.m @@ -43,10 +43,9 @@ typedef enum { @implementation SlideNavigationController -NSString * const SlideNavigationControllerWillOpen = @"SlideNavigationControllerWillOpen"; NSString * const SlideNavigationControllerDidOpen = @"SlideNavigationControllerDidOpen"; NSString * const SlideNavigationControllerDidClose = @"SlideNavigationControllerDidClose"; -NSString * const SlideNavigationControllerDidReveal = @"SlideNavigationControllerDidReveal"; +NSString *const SlideNavigationControllerDidReveal = @"SlideNavigationControllerDidReveal"; #define MENU_SLIDE_ANIMATION_DURATION .3 #define MENU_SLIDE_ANIMATION_OPTION UIViewAnimationOptionCurveEaseOut @@ -521,7 +520,7 @@ static SlideNavigationController *singletonInstance; - (void)moveHorizontallyToLocation:(CGFloat)location { CGRect rect = self.view.frame; - UIDeviceOrientation orientation = [UIDevice currentDevice].orientation; + UIInterfaceOrientation orientation = self.interfaceOrientation; Menu menu = (self.horizontalLocation >= 0 && location >= 0) ? MenuLeft : MenuRight; if ((location > 0 && self.horizontalLocation <= 0) || (location < 0 && self.horizontalLocation >= 0)) { @@ -535,14 +534,14 @@ static SlideNavigationController *singletonInstance; } else { - if (UIDeviceOrientationIsLandscape(orientation)) + if (UIInterfaceOrientationIsLandscape(orientation)) { rect.origin.x = 0; - rect.origin.y = (orientation == UIDeviceOrientationLandscapeRight) ? location*-1 : location; + rect.origin.y = (orientation == UIInterfaceOrientationLandscapeRight) ? location : location*-1; } else { - rect.origin.x = (orientation == UIDeviceOrientationPortrait) ? location : location*-1; + rect.origin.x = (orientation == UIInterfaceOrientationPortrait) ? location : location*-1; rect.origin.y = 0; } } @@ -571,18 +570,16 @@ static SlideNavigationController *singletonInstance; return rect; } - UIDeviceOrientation orientation = [UIDevice currentDevice].orientation; - - if (UIDeviceOrientationIsLandscape(orientation)) + if (UIInterfaceOrientationIsLandscape(self.interfaceOrientation)) { // For some reasons in landscape below the status bar is considered y=0, but in portrait it's considered y=20 - rect.origin.x = (orientation == UIDeviceOrientationLandscapeRight) ? 0 : STATUS_BAR_HEIGHT; + rect.origin.x = (self.interfaceOrientation == UIInterfaceOrientationLandscapeRight) ? 0 : STATUS_BAR_HEIGHT; rect.size.width = self.view.frame.size.width-STATUS_BAR_HEIGHT; } else { // For some reasons in landscape below the status bar is considered y=0, but in portrait it's considered y=20 - rect.origin.y = (orientation == UIDeviceOrientationPortrait) ? STATUS_BAR_HEIGHT : 0; + rect.origin.y = (self.interfaceOrientation == UIInterfaceOrientationPortrait) ? STATUS_BAR_HEIGHT : 0; rect.size.height = self.view.frame.size.height-STATUS_BAR_HEIGHT; } @@ -606,14 +603,12 @@ static SlideNavigationController *singletonInstance; [self updateMenuFrameAndTransformAccordingToOrientation]; [self.menuRevealAnimator prepareMenuForAnimation:menu]; - - [self postNotificationWithName:SlideNavigationControllerWillOpen forMenu:menu]; } - (CGFloat)horizontalLocation { CGRect rect = self.view.frame; - UIDeviceOrientation orientation = [UIDevice currentDevice].orientation; + UIInterfaceOrientation orientation = self.interfaceOrientation; if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")) { @@ -621,15 +616,15 @@ static SlideNavigationController *singletonInstance; } else { - if (UIDeviceOrientationIsLandscape(orientation)) + if (UIInterfaceOrientationIsLandscape(orientation)) { - return (orientation == UIDeviceOrientationLandscapeRight) - ? rect.origin.y*-1 - : rect.origin.y; + return (orientation == UIInterfaceOrientationLandscapeRight) + ? rect.origin.y + : rect.origin.y*-1; } else { - return (orientation == UIDeviceOrientationPortrait) + return (orientation == UIInterfaceOrientationPortrait) ? rect.origin.x : rect.origin.x*-1; } @@ -639,7 +634,7 @@ static SlideNavigationController *singletonInstance; - (CGFloat)horizontalSize { CGRect rect = self.view.frame; - UIDeviceOrientation orientation = [UIDevice currentDevice].orientation; + UIInterfaceOrientation orientation = self.interfaceOrientation; if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")) { @@ -647,7 +642,7 @@ static SlideNavigationController *singletonInstance; } else { - if (UIDeviceOrientationIsLandscape(orientation)) + if (UIInterfaceOrientationIsLandscape(orientation)) { return rect.size.height; } @@ -680,7 +675,7 @@ static SlideNavigationController *singletonInstance; - (CGFloat)slideOffset { - return (UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation)) + return (UIInterfaceOrientationIsLandscape(self.interfaceOrientation)) ? self.landscapeSlideOffset : self.portraitSlideOffset; }