Skip to content

Commit

Permalink
Fixed issue #9
Browse files Browse the repository at this point in the history
  • Loading branch information
Terry Worona committed Mar 13, 2014
1 parent 43045f1 commit 231b388
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
7 changes: 5 additions & 2 deletions Classes/TWMessageBarManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,12 @@ typedef enum {
- (void)showMessageWithTitle:(NSString *)title description:(NSString *)description type:(TWMessageBarMessageType)type duration:(CGFloat)duration callback:(void (^)())callback;

/**
* Hides the topmost message from view and removes all remaining messages in the queue (not animated).
* Hides the topmost message and removes all remaining messages in the queue.
*
* @param animated Animates the current message view off the screen.
*/
- (void)hideAll;
- (void)hideAllAnimated:(BOOL)animated;
- (void)hideAll; // non-animated

@end

Expand Down
24 changes: 19 additions & 5 deletions Classes/TWMessageBarManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -180,16 +180,25 @@ - (void)showMessageWithTitle:(NSString *)title description:(NSString *)descripti
}
}

- (void)hideAll
- (void)hideAllAnimated:(BOOL)animated
{
TWMessageView *currentMessageView = nil;

for (UIView *subview in [[[UIApplication sharedApplication] keyWindow] subviews])
{
if ([subview isKindOfClass:[TWMessageView class]])
{
currentMessageView = (TWMessageView *)subview;
[currentMessageView removeFromSuperview];
TWMessageView *currentMessageView = (TWMessageView *)subview;
if (animated)
{
[UIView animateWithDuration:kTWMessageBarManagerDismissAnimationDuration animations:^{
currentMessageView.frame = CGRectMake(currentMessageView.frame.origin.x, -currentMessageView.frame.size.height, currentMessageView.frame.size.width, currentMessageView.frame.size.height);
} completion:^(BOOL finished) {
[currentMessageView removeFromSuperview];
}];
}
else
{
[currentMessageView removeFromSuperview];
}
}
}

Expand All @@ -198,6 +207,11 @@ - (void)hideAll
[NSObject cancelPreviousPerformRequestsWithTarget:self];
}

- (void)hideAll
{
[self hideAllAnimated:NO];
}

#pragma mark - Helpers

- (void)showNextMessage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ - (void)infoButtonPressed:(id)sender

- (void)hideAllButtonPressed:(id)sender
{
[[TWMessageBarManager sharedInstance] hideAll];
[[TWMessageBarManager sharedInstance] hideAllAnimated:YES];
}

#pragma mark - Generators
Expand Down

0 comments on commit 231b388

Please sign in to comment.