Browse files

added more callback delegate methods

  • Loading branch information...
1 parent ff4ad9a commit 240d56131cff10f24a3738d7568767a0f5957752 @coneybeare coneybeare committed Jan 12, 2012
View
BIN ...proj/project.xcworkspace/xcuserdata/coneybeare.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
View
3 UAModalPanel/UAModalPanel.h
@@ -20,7 +20,10 @@
@protocol UAModalPanelDelegate
@optional
+- (void)willShowModalPanel:(UAModalPanel *)modalPanel;
+- (void)didShowModalPanel:(UAModalPanel *)modalPanel;
- (BOOL)shouldCloseModalPanel:(UAModalPanel *)modalPanel;
+- (void)willCloseModalPanel:(UAModalPanel *)modalPanel;
- (void)didCloseModalPanel:(UAModalPanel *)modalPanel;
@end
View
16 UAModalPanel/UAModalPanel.m
@@ -201,6 +201,10 @@ - (void)showAnimationPart2Finished {}; //subcalsses override
- (void)showAnimationPart3Finished {}; //subcalsses override
- (void)showAnimationFinished {}; //subcalsses override
- (void)show {
+
+ if ([delegate respondsToSelector:@selector(willShowModalPanel:)])
+ [delegate willShowModalPanel:self];
+
[self showAnimationStarting];
self.alpha = 0.0;
self.contentContainer.transform = CGAffineTransformMakeScale(0.00001, 0.00001);
@@ -230,7 +234,9 @@ - (void)show {
self.contentContainer.transform = CGAffineTransformIdentity;
}
completion:^(BOOL finished){
- [self showAnimationFinished];
+ [self showAnimationFinished];
+ if ([delegate respondsToSelector:@selector(didShowModalPanel:)])
+ [delegate didShowModalPanel:self];
}];
}];
}];
@@ -247,6 +253,8 @@ - (void)show {
}
completion:(shouldBounce ? animationBlock : ^(BOOL finished) {
[self showAnimationFinished];
+ if ([delegate respondsToSelector:@selector(didShowModalPanel:)])
+ [delegate didShowModalPanel:self];
})];
}
@@ -258,6 +266,9 @@ - (void)showFromPoint:(CGPoint)point {
- (void)hide {
// Hide the view right away
+ if ([delegate respondsToSelector:@selector(willCloseModalPanel:)])
+ [delegate willCloseModalPanel:self];
+
[UIView animateWithDuration:0.3
animations:^{
self.alpha = 0;
@@ -269,9 +280,8 @@ - (void)hide {
completion:^(BOOL finished){
if ([delegate respondsToSelector:@selector(didCloseModalPanel:)]) {
[delegate didCloseModalPanel:self];
- } else {
- [self removeFromSuperview];
}
+ [self removeFromSuperview];
}];
}
View
24 UAModalPanel/UAViewController.m
@@ -75,21 +75,37 @@ - (IBAction)showModalPanel:(id)sender {
#pragma mark - UAModalDisplayPanelViewDelegate
+// Optional: This is called before the open animations.
+// Only used if delegate is set.
+- (void)willShowModalPanel:(UAModalPanel *)modalPanel {
+ UADebugLog(@"willShowModalPanel called with modalPanel: %@", modalPanel);
+}
+
+// Optional: This is called after the open animations.
+// Only used if delegate is set.
+- (void)didShowModalPanel:(UAModalPanel *)modalPanel {
+ UADebugLog(@"didShowModalPanel called with modalPanel: %@", modalPanel);
+}
+
// Optional: This is called when the close button is pressed
// You can use it to perform validations
// Return YES to close the panel, otherwise NO
-// Only used if delegate is set. You can use blocks instead
+// Only used if delegate is set.
- (BOOL)shouldCloseModalPanel:(UAModalPanel *)modalPanel {
UADebugLog(@"shouldCloseModalPanel called with modalPanel: %@", modalPanel);
return YES;
}
+// Optional: This is called before the close animations.
+// Only used if delegate is set.
+- (void)willCloseModalPanel:(UAModalPanel *)modalPanel {
+ UADebugLog(@"willCloseModalPanel called with modalPanel: %@", modalPanel);
+}
+
// Optional: This is called after the close animations.
-// If you store a local iVar, you could remove the view from the superview here and cleanup
-// Only used if delegate is set. You can use blocks instead
+// Only used if delegate is set.
- (void)didCloseModalPanel:(UAModalPanel *)modalPanel {
UADebugLog(@"didCloseModalPanel called with modalPanel: %@", modalPanel);
- [modalPanel removeFromSuperview];
}

0 comments on commit 240d561

Please sign in to comment.