3

I have some source code below which will reproduce this. Calling showWithStatus and dismiss before the HUD has a chance to present itself is causing the control to not show the next time showWithStatus is called. Does anyone know any workarounds?

// Commenting these will show SVProgressHUD
[SVProgressHUD showWithStatus:@"Loading..."];
[SVProgressHUD dismiss];
// Comment above to show SVProgressHUD

[SVProgressHUD showWithStatus:@"Loading..."];
[self performSelector:@selector(dismissHUD) withObject:nil afterDelay:5.0f];

EDIT: I have some source code up here that reproduces this.

Tejaswi Yerukalapudi
  • 8,987
  • 12
  • 60
  • 101
  • Would be good to file a bug report on the official GitHub project as well. The author possibly knows the answer off the top of his head. Nevertheless, +1 for providing a test case. – jweyrich Mar 12 '14 at 19:14
  • I did .. But there were several open issues there, and thought I might get help quicker here :) – Tejaswi Yerukalapudi Mar 12 '14 at 19:17
  • Sure, nothing wrong with that. Just find it important to notify the maintainer so others (myself included) won't run over the same issues in the future. Glad you did :-) I'll post a comment over there so hopefully it attracts more attention. – jweyrich Mar 12 '14 at 19:23

2 Answers2

0

I worked around it by doing this for the second HUD display:

[self performSelector:@selector(showHud) withObject:nil afterDelay:0.1];
Germán
  • 4,525
  • 3
  • 31
  • 37
0

I have resolved the problem:

1. add property

@property (nonatomic, readonly, getter = isDismissing) BOOL dismissing;

2.add flag

- (void)dismissWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay {
    _dismissing = YES;
    ...
        void (^completionBlock)(void) = ^{
            ...
            _dismissing = NO;
        };
    ...
}

Rename function

- (void)showImage:(UIImage)image status:(NSString)status duration:(NSTimeInterval)duration  

to with name

- (void)showImageSS:(UIImage)image status:(NSString)status duration:(NSTimeInterval)duration

3.add delay

- (void)showImage:(UIImage*)image status:(NSString*)status duration:(NSTimeInterval)duration
{
    if(self.isDismissing){
        __weak SVProgressHUD *weakSelf = self;
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_SEC * SVProgressHUDDefaultAnimationDuration),dispatch_get_main_queue(), ^{
            [weakSelf showImageSS:image status:status duration:duration];
        });
    }else{
        [self showImageSS:image status:status duration:duration];
    }
}

And

- (void)showImageSS:(UIImage*)image status:(NSString*)status duration:(NSTimeInterval)duration
{
    // this is orginal function - (void)showImage:(UIImage)image status:(NSString)status duration:(NSTimeInterval)duration code block
}  

finsh Thanks Everybody

Gennadii Saprykin
  • 4,505
  • 8
  • 31
  • 41
xabstan
  • 1
  • 1