Permalink
Browse files

Add delegate method for aligning of the stack

  • Loading branch information...
1 parent bbf898c commit 150b81d6cedb4de7b5b5faf6fbe7e6c2ceb00881 @coreyfloyd coreyfloyd committed with Feb 13, 2012
Showing with 21 additions and 1 deletion.
  1. +18 −1 PSStackedView/PSStackedViewController.m
  2. +3 −0 PSStackedView/PSStackedViewDelegate.h
@@ -41,6 +41,7 @@ @interface PSStackedViewController() <UIGestureRecognizerDelegate> {
unsigned int delegateWillRemoveViewController:1;
unsigned int delegateDidRemoveViewController:1;
unsigned int delegateDidPanViewController:1;
+ unsigned int delegateDidAlign:1;
}delegateFlags_;
}
@property(nonatomic, strong) UIViewController *rootViewController;
@@ -127,6 +128,8 @@ - (void)setDelegate:(id<PSStackedViewDelegate>)delegate {
delegateFlags_.delegateWillRemoveViewController = [delegate respondsToSelector:@selector(stackedView:willRemoveViewController:)];
delegateFlags_.delegateDidRemoveViewController = [delegate respondsToSelector:@selector(stackedView:didRemoveViewController:)];
delegateFlags_.delegateDidPanViewController = [delegate respondsToSelector:@selector(stackedView:didPanViewController:byOffset:)];
+ delegateFlags_.delegateDidAlign = [delegate respondsToSelector:@selector(stackedViewDidAlign:)];
+
}
}
@@ -160,6 +163,12 @@ - (void)delegateDidPanViewController:(UIViewController *)viewController byOffset
}
}
+- (void)delegateDidAlign{
+ if (delegateFlags_.delegateDidAlign) {
+ [self.delegate stackedViewDidAlign:self];
+ }
+}
+
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma mark - Private Helpers
@@ -1225,21 +1234,29 @@ - (void)alignStackAnimated:(BOOL)animated duration:(CGFloat)duration bounceType:
[self alignStackAnimated:YES duration:animationDuration bounceType:PSSVBounceBack];
}break;
- // we're done here
case PSSVBounceNone:
+ [self delegateDidAlign];
case PSSVBounceBack:
+ [self delegateDidAlign];
+
default: {
lastDragOffset_ = 0; // clear last drag offset for the animation
//[self removeAnimationBlockerView];
}break;
}
+ }else if(finished){
+
+ [self delegateDidAlign];
+
}
}
];
}
else {
alignmentBlock();
+ //[self delegateDidAlign];
+
}
}
@@ -29,4 +29,7 @@
/// viewController has been panned
- (void)stackedView:(PSStackedViewController *)stackedView didPanViewController:(UIViewController *)viewController byOffset:(NSInteger)offset;
+/// viewController has been aligned (programmatically or by result of panning)
+- (void)stackedViewDidAlign:(PSStackedViewController *)stackedView;
+
@end

0 comments on commit 150b81d

Please sign in to comment.