6

I am using a MBProgressHUD view to show loading state when i am downloading something from the Internet. When download is finished, i call the hide method to hide the view. I want to use a timer to judge whether download is finished by checking the view's hidden, namely, isHidden method. But when i set the view 's hide to YES, then check isHidden method, it returns NO. I don't know why the view works like this?

some snippets are as follows:

MBProgressHUD   *HUD; // instance variable

In the download finished method:

[HUD hide:YES];
NSLog(@"HUD isHidden: %@",[HUD isHidden] ? @"YES" : @"NO");

When the method is called, the output is NO.

iPatel
  • 46,010
  • 16
  • 115
  • 137
chancyWu
  • 14,073
  • 11
  • 62
  • 81

2 Answers2

5

As per MBProgressHUD's implementation, they don't hide it using hidden property of UIView. They just sets alpha of MBProgressHUD to 0 so that it will not be visible.

Rahul Wakade
  • 4,765
  • 2
  • 23
  • 25
  • Thanks for your response, I have checked the hide: method implementation. As you said, they set the alpha value to 0 and didn't use the hidden property of UIView. I wonder whether they should update the hidden property ? – chancyWu Jan 23 '13 at 09:02
4

I Found That:

In MBProgressHUD isHidden Method By default set NO so you can get all time to (When you check) NO. You doesn't check in superviews.

For Check MBProgressHUD Status hide/show.

Set [HUD setHidden:YES]; after [HUD hide:YES]; then after it will work fine .

NSLog(@"HUD isHidden: %@",[HUD isHidden] ? @"YES" : @"NO");
//Output in consol YES
iPatel
  • 46,010
  • 16
  • 115
  • 137
  • yes, you are right. I checked the hide implementation, it change the alpha value to 0 to hide the view and didn't update the hidden property. And in your way, i can check the is hidden value.thanks your answer. – chancyWu Jan 23 '13 at 09:14
  • but i think Rahul's answer is better for me. he show me the hide implementation. i will vote for you – chancyWu Jan 23 '13 at 09:17