0

I have implemented Reachability.h from Apple into my demo app. The problem is that I noticed that my app stalls while checking connection.

So, I added an Activity Indicator (From MBProgressHUD) . But the indicator does not animate. It stalls with the application too.

So, I thought of putting the activity indicator inside another thread different than the main thread but still it is not animating.

Note: I'm not very experienced

UPDATE: Also, I have tried the native Activity Indicator with no luck.

- (void)anotherThread
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 


    HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
    [self.navigationController.view addSubview:HUD];

    // Set determinate mode
    HUD.mode = MBProgressHUDModeDeterminate;

    HUD.delegate = self;
    HUD.labelText = @"loading";

    // myProgressTask uses the HUD instance to update progress
    [HUD showWhileExecuting:@selector(crazyCounter) onTarget:self withObject:nil animated:YES];

    [pool release];  
}
Sobiaholic
  • 2,927
  • 9
  • 37
  • 54

1 Answers1

1

UI code should be kept in main thread. So instead of putting the activity indicator into another thread, you may want to use GCD (grand central dispatch) to throw your checking connection code in another thread. When it finishes, you can then remove or hide your activity indicator.

PS. I'm not quite sure what MBProgressHUD does, but you do want to make sure you have something like [activityIndicator startAnimating]. At least for normal activity indicators, you need to manually turn it on.

danqing
  • 3,348
  • 2
  • 27
  • 43