iphoneiossvprogresshud

Activity Indicator is not showing with SVProgressHUD


I am trying to implement the SVProgressHUD progress activity indicator. I copied the class from the [demo].1

My app loads up but the activity indicator doesn't show up. This is my first time trying to use one of these, so any help would be appreciated.

Here is the code:

#import "SVProgressHUD.h"

@implementation QuotesAppDelegate

- (void)startLoading 
{
    //call this in your app delegate instead of setting window.rootViewController to your main view controller
    //you can show a UIActivityIndiocatorView here or something if you like
    [SVProgressHUD show];
    [self performSelectorInBackground:@selector(loadInBackground) withObject:nil];
}

- (void)loadInBackground
{ 
    //do your loading here
    //this is in the background, so don't try to access any UI elements
    [self populateFromDatabase];

    [SVProgressHUD dismiss];

    [self performSelectorOnMainThread:@selector(finishedLoading) withObject:nil waitUntilDone:NO];
}

- (void)finishedLoading
{
    //back on the main thread now, it's safe to show your view controller
    [window addSubview:[navigationController view]];
    [window makeKeyAndVisible];
}


- (void)applicationDidFinishLaunching:(UIApplication *)application {

    [self copyDatabaseIfNeeded];

    [self startLoading];
}

Solution

  • First of all you were not adding your SVProgressHUD to the view.

    If your class inherited from UIViewController then [self.view addSubview:]; or if your class is simple UIView then [self addSubView:];

    I do not understand your requirement but as far as i can understand through your code that you are showing [SVProgressHUD show]; in your startLoading method and then you are calling loadInBackground method in that method where you are hiding your hud using [SVProgressHUD dismiss];

    I will suggest you to trace it by using breakpoint and figure it out.