Permalink
Browse files

Added didPanViewController:byOffset delegate method to PSStacked VC.

  • Loading branch information...
1 parent 888a831 commit 76c6c7f685eba7217c94c727c3caa729f7a04ced Christopher Constable committed Jan 23, 2012
Showing with 17 additions and 1 deletion.
  1. +14 −1 PSStackedView/PSStackedViewController.m
  2. +3 −0 PSStackedView/PSStackedViewDelegate.h
View
15 PSStackedView/PSStackedViewController.m
@@ -39,7 +39,8 @@ @interface PSStackedViewController() <UIGestureRecognizerDelegate> {
unsigned int delegateWillInsertViewController:1;
unsigned int delegateDidInsertViewController:1;
unsigned int delegateWillRemoveViewController:1;
- unsigned int delegateDidRemoveViewController:1;
+ unsigned int delegateDidRemoveViewController:1;
+ unsigned int delegateDidPanViewController:1;
}delegateFlags_;
}
@property(nonatomic, strong) UIViewController *rootViewController;
@@ -123,6 +124,7 @@ - (void)setDelegate:(id<PSStackedViewDelegate>)delegate {
delegateFlags_.delegateDidInsertViewController = [delegate respondsToSelector:@selector(stackedView:didInsertViewController:)];
delegateFlags_.delegateWillRemoveViewController = [delegate respondsToSelector:@selector(stackedView:willRemoveViewController:)];
delegateFlags_.delegateDidRemoveViewController = [delegate respondsToSelector:@selector(stackedView:didRemoveViewController:)];
+ delegateFlags_.delegateDidPanViewController = [delegate respondsToSelector:@selector(stackedView:didPanViewController:byOffset:)];
}
}
@@ -150,6 +152,12 @@ - (void)delegateDidRemoveViewController:(UIViewController *)viewController {
}
}
+- (void)delegateDidPanViewController:(UIViewController *)viewController byOffset:(NSInteger)offset {
+ if (delegateFlags_.delegateDidPanViewController) {
+ [self.delegate stackedView:self didPanViewController:viewController byOffset:offset];
+ }
+}
+
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma mark - Private Helpers
@@ -654,6 +662,11 @@ - (void)stopStackAnimation {
- (void)moveStackWithOffset:(NSInteger)offset animated:(BOOL)animated userDragging:(BOOL)userDragging {
PSSVLog(@"moving stack on %d pixels (animated:%d, decellerating:%d)", offset, animated, userDragging);
+ // let the delegate know the user is moving the stack
+ if (self.delegate && userDragging) {
+ [self delegateDidPanViewController:self.topViewController byOffset:offset];
+ }
+
[self stopStackAnimation];
[UIView animateWithDuration:animated ? kPSSVStackAnimationDuration : 0.f delay:0.f options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionAllowUserInteraction animations:^{
View
3 PSStackedView/PSStackedViewDelegate.h
@@ -26,4 +26,7 @@
/// viewController has been removed
- (void)stackedView:(PSStackedViewController *)stackedView didRemoveViewController:(UIViewController *)viewController;
+/// viewController has been panned
+- (void)stackedView:(PSStackedViewController *)stackedView didPanViewController:(UIViewController *)viewController byOffset:(NSInteger)offset;
+
@end

0 comments on commit 76c6c7f

Please sign in to comment.