Skip to content

Commit

Permalink
Added feature to display an error overlay until manually dismissed.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpm committed Apr 16, 2012
1 parent 8b2f1f8 commit cb2d915
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions SVProgressHUD/SVProgressHUD.h
Expand Up @@ -31,6 +31,8 @@ typedef NSUInteger SVProgressHUDMaskType;
+ (void)showErrorWithStatus:(NSString *)string;
+ (void)showErrorWithStatus:(NSString *)string duration:(NSTimeInterval)duration;

+ (void)showErrorUntilDismissedWithStatus:(NSString *)string;

+ (void)setStatus:(NSString*)string; // change the HUD loading status while it's showing

+ (void)dismiss; // simply dismiss the HUD with a fade+scale out animation
Expand Down
14 changes: 13 additions & 1 deletion SVProgressHUD/SVProgressHUD.m
Expand Up @@ -118,6 +118,18 @@ + (void)showErrorWithStatus:(NSString *)string duration:(NSTimeInterval)duration
[SVProgressHUD dismissWithError:string afterDelay:duration];
}

+ (void)showErrorUntilDismissedWithStatus:(NSString *)string {
[SVProgressHUD showWithMaskType:SVProgressHUDMaskTypeClear];
[SVProgressHUD dismissWithError:string afterDelay:MAXFLOAT];

// add hidden button to handle the dismiss feature
SVProgressHUD *topView = [SVProgressHUD sharedView];
UIButton *b = [UIButton buttonWithType:UIButtonTypeCustom];
b.frame = topView.hudView.bounds;
[b addTarget:topView action:@selector(dismiss) forControlEvents:UIControlEventTouchUpInside];
[topView.hudView addSubview:b];
}


#pragma mark - Dismiss Methods

Expand Down Expand Up @@ -148,7 +160,7 @@ - (id)initWithFrame:(CGRect)frame {

if ((self = [super initWithFrame:frame])) {
[self.overlayWindow addSubview:self];
self.userInteractionEnabled = NO;
self.userInteractionEnabled = YES;
self.backgroundColor = [UIColor clearColor];
self.alpha = 0;
self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
Expand Down

0 comments on commit cb2d915

Please sign in to comment.