Merge pull request #29 from thomashempel/master

Adding notifications for left or right will disappear
This commit is contained in:
Leon Gersing
2012-10-01 16:39:27 -07:00
2 changed files with 27 additions and 5 deletions

View File

@@ -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;

View File

@@ -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) {