From 1b8f16910b8721956b3907b495dfbde1198f7170 Mon Sep 17 00:00:00 2001 From: Thomas Hempel Date: Tue, 24 Jul 2012 22:14:26 +0200 Subject: [PATCH] Add notifications for UnderLeftWillDisappear and UnderRightWillDisappear --- .../ECSlidingViewController.h | 6 +++++ .../ECSlidingViewController.m | 26 +++++++++++++++---- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/ECSlidingViewController/Vendor/ECSlidingViewController/ECSlidingViewController.h b/ECSlidingViewController/Vendor/ECSlidingViewController/ECSlidingViewController.h index a4a4e99..fac4e40 100644 --- a/ECSlidingViewController/Vendor/ECSlidingViewController/ECSlidingViewController.h +++ b/ECSlidingViewController/Vendor/ECSlidingViewController/ECSlidingViewController.h @@ -15,6 +15,12 @@ extern NSString *const ECSlidingViewUnderRightWillAppear; /** Notification that gets posted when the underLeft view will appear */ extern NSString *const ECSlidingViewUnderLeftWillAppear; +/** Notification that gets posted when the underLeft view will disappear */ +extern NSString *const ECSlidingViewUnderLeftWillDisappear; + +/** Notification that gets posted when the underRight view will disappear */ +extern NSString *const ECSlidingViewUnderRightWillDisappear; + /** Notification that gets posted when the top view is anchored to the left side of the screen */ extern NSString *const ECSlidingViewTopDidAnchorLeft; diff --git a/ECSlidingViewController/Vendor/ECSlidingViewController/ECSlidingViewController.m b/ECSlidingViewController/Vendor/ECSlidingViewController/ECSlidingViewController.m index 8b27a21..3cf8504 100644 --- a/ECSlidingViewController/Vendor/ECSlidingViewController/ECSlidingViewController.m +++ b/ECSlidingViewController/Vendor/ECSlidingViewController/ECSlidingViewController.m @@ -8,11 +8,13 @@ #import "ECSlidingViewController.h" -NSString *const ECSlidingViewUnderRightWillAppear = @"ECSlidingViewUnderRightWillAppear"; -NSString *const ECSlidingViewUnderLeftWillAppear = @"ECSlidingViewUnderLeftWillAppear"; -NSString *const ECSlidingViewTopDidAnchorLeft = @"ECSlidingViewTopDidAnchorLeft"; -NSString *const ECSlidingViewTopDidAnchorRight = @"ECSlidingViewTopDidAnchorRight"; -NSString *const ECSlidingViewTopDidReset = @"ECSlidingViewTopDidReset"; +NSString *const ECSlidingViewUnderRightWillAppear = @"ECSlidingViewUnderRightWillAppear"; +NSString *const ECSlidingViewUnderLeftWillAppear = @"ECSlidingViewUnderLeftWillAppear"; +NSString *const ECSlidingViewUnderLeftWillDisappear = @"ECSlidingViewUnderLeftWillDisappear"; +NSString *const ECSlidingViewUnderRightWillDisappear = @"ECSlidingViewUnderRightWillDisappear"; +NSString *const ECSlidingViewTopDidAnchorLeft = @"ECSlidingViewTopDidAnchorLeft"; +NSString *const ECSlidingViewTopDidAnchorRight = @"ECSlidingViewTopDidAnchorRight"; +NSString *const ECSlidingViewTopDidReset = @"ECSlidingViewTopDidReset"; @interface ECSlidingViewController() @@ -408,8 +410,22 @@ NSString *const ECSlidingViewTopDidReset = @"ECSlidingViewTopDidReset"; - (void)topViewHorizontalCenterWillChange:(CGFloat)newHorizontalCenter { + + CGPoint center = self.topView.center; + if (center.x >= self.resettedCenter && newHorizontalCenter == self.resettedCenter) { + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:ECSlidingViewUnderLeftWillDisappear object:self userInfo:nil]; + }); + } + + if (center.x <= self.resettedCenter && newHorizontalCenter == self.resettedCenter) { + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:ECSlidingViewUnderRightWillDisappear object:self userInfo:nil]; + }); + } + if (center.x <= self.resettedCenter && newHorizontalCenter > self.resettedCenter) { [self underLeftWillAppear]; } else if (center.x >= self.resettedCenter && newHorizontalCenter < self.resettedCenter) {