Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 688
chancyWu Avatar asked Jan 23 '13 08:01

chancyWu


2 Answers

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.

like image 69
Rahul Wakade Avatar answered Nov 11 '22 04:11

Rahul Wakade


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
like image 31
iPatel Avatar answered Nov 11 '22 05:11

iPatel