Permalink
Browse files

Added feature to display an error overlay until manually dismissed.

  • Loading branch information...
1 parent 8b2f1f8 commit cb2d915f8f0d980927bd5af3bba5af91894498f1 @jpm committed Apr 16, 2012
Showing with 15 additions and 1 deletion.
  1. +2 −0 SVProgressHUD/SVProgressHUD.h
  2. +13 −1 SVProgressHUD/SVProgressHUD.m
@@ -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
@@ -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
@@ -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;

0 comments on commit cb2d915

Please sign in to comment.