diff --git a/SlideMenu.xcodeproj/project.pbxproj b/SlideMenu.xcodeproj/project.pbxproj index 6f27f56..5006a3d 100755 --- a/SlideMenu.xcodeproj/project.pbxproj +++ b/SlideMenu.xcodeproj/project.pbxproj @@ -69,7 +69,7 @@ 15371EF81728E3B400A508F4 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 15371EFB1728E3B400A508F4 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = en; path = en.lproj/MainStoryboard_iPhone.storyboard; sourceTree = ""; }; 15371EFE1728E3B400A508F4 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = en; path = en.lproj/MainStoryboard_iPad.storyboard; sourceTree = ""; }; - 15371F081728E3B400A508F4 /* SlideMenuTests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SlideMenuTests.octest; sourceTree = BUILT_PRODUCTS_DIR; }; + 15371F081728E3B400A508F4 /* SlideMenuTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SlideMenuTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 15371F111728E3B400A508F4 /* SlideMenuTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "SlideMenuTests-Info.plist"; sourceTree = ""; }; 15371F131728E3B400A508F4 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 15371F151728E3B400A508F4 /* SlideMenuTests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SlideMenuTests.h; sourceTree = ""; }; @@ -146,7 +146,7 @@ isa = PBXGroup; children = ( 15371EDE1728E3B400A508F4 /* SlideMenu.app */, - 15371F081728E3B400A508F4 /* SlideMenuTests.octest */, + 15371F081728E3B400A508F4 /* SlideMenuTests.xctest */, ); name = Products; sourceTree = ""; @@ -314,7 +314,7 @@ ); name = SlideMenuTests; productName = SlideMenuTests; - productReference = 15371F081728E3B400A508F4 /* SlideMenuTests.octest */; + productReference = 15371F081728E3B400A508F4 /* SlideMenuTests.xctest */; productType = "com.apple.product-type.bundle.unit-test"; }; /* End PBXNativeTarget section */ diff --git a/SlideMenu/AppDelegate.m b/SlideMenu/AppDelegate.m index c49d7b0..e48a2ea 100644 --- a/SlideMenu/AppDelegate.m +++ b/SlideMenu/AppDelegate.m @@ -30,6 +30,21 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( [button addTarget:[SlideNavigationController sharedInstance] action:@selector(toggleRightMenu) forControlEvents:UIControlEventTouchUpInside]; UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button]; [SlideNavigationController sharedInstance].rightBarButtonItem = rightBarButtonItem; + + [[NSNotificationCenter defaultCenter] addObserverForName:SlideNavigationControllerDidClose object:nil queue:nil usingBlock:^(NSNotification *note) { + NSString *menu = note.userInfo[@"menu"]; + NSLog(@"Closed %@", menu); + }]; + + [[NSNotificationCenter defaultCenter] addObserverForName:SlideNavigationControllerDidOpen object:nil queue:nil usingBlock:^(NSNotification *note) { + NSString *menu = note.userInfo[@"menu"]; + NSLog(@"Opened %@", menu); + }]; + + [[NSNotificationCenter defaultCenter] addObserverForName:SlideNavigationControllerDidReveal object:nil queue:nil usingBlock:^(NSNotification *note) { + NSString *menu = note.userInfo[@"menu"]; + NSLog(@"Revealed %@", menu); + }]; // Override point for customization after application launch. diff --git a/SlideMenu/Source/SlideNavigationController.h b/SlideMenu/Source/SlideNavigationController.h index f7bc2ac..2a44a54 100644 --- a/SlideMenu/Source/SlideNavigationController.h +++ b/SlideMenu/Source/SlideNavigationController.h @@ -42,6 +42,10 @@ typedef enum{ @protocol SlideNavigationContorllerAnimator; @interface SlideNavigationController : UINavigationController +extern NSString * const SlideNavigationControllerDidOpen; +extern NSString *const SlideNavigationControllerDidClose; +extern NSString *const SlideNavigationControllerDidReveal; + @property (nonatomic, assign) BOOL avoidSwitchingToSameClassViewController; @property (nonatomic, assign) BOOL enableSwipeGesture; @property (nonatomic, assign) BOOL enableShadow; diff --git a/SlideMenu/Source/SlideNavigationController.m b/SlideMenu/Source/SlideNavigationController.m index 0c23e66..280160d 100644 --- a/SlideMenu/Source/SlideNavigationController.m +++ b/SlideMenu/Source/SlideNavigationController.m @@ -42,6 +42,10 @@ @interface SlideNavigationController() @implementation SlideNavigationController +NSString * const SlideNavigationControllerDidOpen = @"SlideNavigationControllerDidOpen"; +NSString * const SlideNavigationControllerDidClose = @"SlideNavigationControllerDidClose"; +NSString *const SlideNavigationControllerDidReveal = @"SlideNavigationControllerDidReveal"; + #define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) #define MENU_SLIDE_ANIMATION_DURATION .3 #define MENU_QUICK_SLIDE_ANIMATION_DURATION .18 @@ -51,6 +55,9 @@ @implementation SlideNavigationController #define MENU_DEFAULT_SLIDE_OFFSET 60 #define MENU_FAST_VELOCITY_FOR_SWIPE_FOLLOW_DIRECTION 1200 #define STATUS_BAR_HEIGHT 20 +#define NOTIFICATION_USER_INFO_MENU_LEFT @"left" +#define NOTIFICATION_USER_INFO_MENU_RIGHT @"right" +#define NOTIFICATION_USER_INFO_MENU @"menu" static SlideNavigationController *singletonInstance; @@ -462,12 +469,16 @@ - (void)openMenu:(Menu)menu withDuration:(float)duration andCompletion:(void (^) completion:^(BOOL finished) { if (completion) completion(); + + [self postNotificationWithName:SlideNavigationControllerDidOpen forMenu:menu]; }]; } - (void)closeMenuWithDuration:(float)duration andCompletion:(void (^)())completion { [self enableTapGestureToCloseMenu:NO]; + + Menu menu = (self.horizontalLocation > 0) ? MenuLeft : MenuRight; [UIView animateWithDuration:duration delay:0 @@ -480,6 +491,8 @@ - (void)closeMenuWithDuration:(float)duration andCompletion:(void (^)())completi completion:^(BOOL finished) { if (completion) completion(); + + [self postNotificationWithName:SlideNavigationControllerDidClose forMenu:menu]; }]; } @@ -488,6 +501,10 @@ - (void)moveHorizontallyToLocation:(CGFloat)location CGRect rect = self.view.frame; UIInterfaceOrientation orientation = self.interfaceOrientation; Menu menu = (self.horizontalLocation >= 0 && location >= 0) ? MenuLeft : MenuRight; + + if ((location > 0 && self.horizontalLocation <= 0) || (location < 0 && self.horizontalLocation >= 0)) { + [self postNotificationWithName:SlideNavigationControllerDidReveal forMenu:(location > 0) ? MenuLeft : MenuRight]; + } if (UIInterfaceOrientationIsLandscape(orientation)) { @@ -596,6 +613,13 @@ - (CGFloat)horizontalSize } } +- (void)postNotificationWithName:(NSString *)name forMenu:(Menu)menu +{ + NSString *menuString = (menu == MenuLeft) ? NOTIFICATION_USER_INFO_MENU_LEFT : NOTIFICATION_USER_INFO_MENU_RIGHT; + NSDictionary *userInfo = @{ NOTIFICATION_USER_INFO_MENU : menuString }; + [[NSNotificationCenter defaultCenter] postNotificationName:name object:nil userInfo:userInfo]; +} + #pragma mark - UINavigationControllerDelegate Methods - - (void)navigationController:(UINavigationController *)navigationController @@ -624,7 +648,6 @@ - (void)leftMenuSelected:(id)sender [self closeMenuWithCompletion:nil]; else [self openMenu:MenuLeft withCompletion:nil]; - } - (void)righttMenuSelected:(id)sender @@ -670,6 +693,9 @@ - (void)panDetected:(UIPanGestureRecognizer *)aPanRecognizer else currentMenu = (translation.x > 0) ? MenuLeft : MenuRight; + if (![self shouldDisplayMenu:currentMenu forViewController:self.topViewController]) + return; + [self prepareMenuForReveal:currentMenu]; if (aPanRecognizer.state == UIGestureRecognizerStateBegan) diff --git a/iOS-Slide-Menu.podspec b/iOS-Slide-Menu.podspec index ab82d90..be18826 100644 --- a/iOS-Slide-Menu.podspec +++ b/iOS-Slide-Menu.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'iOS-Slide-Menu' - s.version = '1.4.1' + s.version = '1.4.2' s.summary = 'A Slide Menu for iOS' s.homepage = 'https://github.com/aryaxt/iOS-Slide-Menu' s.license = { @@ -8,7 +8,7 @@ Pod::Spec.new do |s| :file => 'License.txt' } s.author = {'Aryan Gh' => 'https://github.com/aryaxt/iOS-Slide-Menu'} - s.source = {:git => 'https://github.com/aryaxt/iOS-Slide-Menu.git', :tag => '1.4.1'} + s.source = {:git => 'https://github.com/aryaxt/iOS-Slide-Menu.git', :tag => '1.4.2'} s.platform = :ios, '6.0' s.source_files = 'SlideMenu/Source/*.{h,m}', 'SlideMenu/Source/Animations/*.{h,m}', 'SlideMenu/Source/Assets/*.{png}' s.resources = ['SlideMenu/Source/Assets/**/*']