Search code examples
iphoneiosobjective-cuiviewmbprogresshud

why set MBProgressHUD's hide to YES, but isHidden method is NO?


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.


Solution

  • 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.