0

I have called SVProgressHUD on viewDidLoad as follows:

[SVProgressHUD showWithStatus:@"Loading"];
[NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error)
{
    if ([data length] > 0 && error == nil)
    {
       //do some task
        [SVProgressHUD dismiss];
    }
}];

But here is what I get: SVProgressHUD is not showing up. Where am I getting wrong? enter image description here

Meet Doshi
  • 4,241
  • 10
  • 40
  • 81
z22
  • 10,013
  • 17
  • 70
  • 126

2 Answers2

1

The issue seems to be that you're calling the show and dismiss methods from a thread other than the main thread. This causes weird issues when you need access to the GUI. When you call the show/hide methods outside of the main thread, use this:

dispatch_async(dispatch_get_main_queue(), ^{
    [SVProgressHUD showWithStatus:@"Loading"];
});

dispatch_async(dispatch_get_main_queue(), ^{
    [SVProgressHUD dismiss];
});
Alex Blundell
  • 2,084
  • 5
  • 22
  • 31
  • i get linker error when I use the above code ERROR:Undefined symbols for architecture i386: "_dipsatch_async", referenced from:.. – z22 Apr 18 '14 at 12:15
  • It's a typo. It should be dispatch (not dipsatch). – hsoi Apr 18 '14 at 12:17
  • Oh yes that was a typo. But with your solution, progressHUD comes n goes very fast, without the loading image. – z22 Apr 18 '14 at 12:25
  • Is it possible the request is completed that fast? – hsoi Apr 18 '14 at 12:27
  • Nope, the progressHUD disappears and I get a blank screen for a long time and then the result is displayed. Plus the progressHUD is seen same as the picture posted above. – z22 Apr 18 '14 at 12:47
  • it might be because you didn't specifically set the type of progress view you wanted – user2277872 Apr 18 '14 at 13:04
  • So what do I need to specify? Please let me know. Even if I specify MaskType, progressHUD gives a square box with nothing loading in it. – z22 Apr 18 '14 at 13:06
  • The only thing I can think of is that you haven't copied the images in correctly. There's a `.bundle` containing the images - is that definitely in your project? Also, make sure you have `QuartzCore` linked – Alex Blundell Apr 18 '14 at 14:11
0

I think you have missed adding SVProgreeHUD.bundle file. Because it is required to display image overlays and also success and error statuses.

Kumar C
  • 525
  • 6
  • 21