3

I'm displaying some views,webVies and while they are loading i display an ProgressHud with waiting message. I'm using an instance of that object :

MBProgressHUD * progrssHUD

Using the show and hide methods to control over loading windows. In some views i would like to add view only after the hide method is turned on - meaning no window displayed now.

How can i check from any interface what is that status of MBProgressHUD and only after status X to do something?

vadim
  • 119
  • 3
  • 14

2 Answers2

3

If you see the implementation of MBProgresshud then you will find that when they are hiding it they are setting it's alpha 0 and when they are showing it they are setting it alpha 1.

So you can use this property to check whether it is hidden or shown. i.e

if(progrssHUD.alpha == 0){
  //perform hide operation
}else{
  //Perform show operation
}
Bùi Đức Khánh
  • 3,975
  • 6
  • 27
  • 43
Sunil Pandey
  • 7,042
  • 7
  • 35
  • 48
  • But how can i connected to that shared instance? if i use `MBProgressHUB *HUB = [MBProgressHUB alloc];` and then i check `HUB.alpha`, it's always 0 even when the `progressHub` is in hide. – vadim Oct 01 '12 at 11:00
  • i don't understand you. If progressHud is hidden then it's alpha value will be 0 and if it is showing it will give you 1 – Sunil Pandey Oct 01 '12 at 11:06
  • yes but i call in from one class and now i want to check it global status(`alpha`) from another class..so if i check with the code above i always getting 0, maybe the problem is that i don't sync to the global instance of that `progressHUD`? – vadim Oct 01 '12 at 11:11
0
-(IBAction)SHOW{
    HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
    [self.navigationController.view addSubview:HUD];
     HUD.delegate = self;
    [HUD show:YES];
    // Show the HUD while the provided method executes in a new thread
    [HUD showWhileExecuting:@selector(showHUD) onTarget:self withObject:nil animated:YES];
      }

- (void)hudWasHidden:(MBProgressHUD *)hud {
    // Remove HUD from screen when the HUD was hidded
    [HUD removeFromSuperview];
    [HUD release];
    HUD = nil;
}

THE METHOD showWhileExecuting CALLING THE HUD WAS ACTIVE WHILE THE DELEGATE METHOD WILL COME.

iPC
  • 5,916
  • 3
  • 26
  • 38