jdg / MBProgressHUD

MBProgressHUD + Customizations
http://www.bukovinski.com/
MIT License
16.01k stars 3.56k forks source link

HUD.userInteractionEnabled = YES doesn't work #470

Open sryze opened 7 years ago

sryze commented 7 years ago

I'm setting userInteractionEnabled to YES to prevent user from clicking on UI elements but it doesn't work, I still can click on anything underneath the HUD.

MBProgessHUD: 0.9.2 iOS 10.3 simulator

sryze commented 7 years ago

Nevermind, found the answer here:

http://stackoverflow.com/questions/5887305/uiview-user-interaction-enabled-false-on-parent-but-true-on-child

I wrapped my HUD in another view and turned off user interaction there. As a result, it was disabled in the HUD itself.

The reason I did that was another wierd issue with MBProgressHUD - despite specifying a frame with an X coordinate > 0 when calling initWithFrame: it was resetting to 0 for some reason. Putting it in a container view fixed that. I guess now I need to find the real reason behind it.

sryze commented 7 years ago
    // Entirely cover the parent view
    UIView *parent = self.superview;
    if (parent) {
        self.frame = parent.bounds;
    }

I don't understand why this is needed, but it would be nice to have this optional if possible.

matej commented 7 years ago

The component was designed to cover the entire parent view and put the bezel in the center. The code snipped you are referring to is there mainly to have the HUD behave correctly during rotation when added to a window on older systems.

But fair point, the HUD should honor your manually set frame, if you wish to do so.

arshadsk5 commented 5 years ago

Even i got same issue, in my objective c project. I fixed the issue as below, but i don't what problem will i get later. Currently it is working fine. -(void)showIndicator { MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:NO]; hud.contentColor = Indicator_FONTRED; hud.bezelView.color = FONTWHITE; [[UIApplication sharedApplication] beginIgnoringInteractionEvents]; }

-(void)hideIndicator { [MBProgressHUD hideHUDForView:self.view animated:NO]; [[UIApplication sharedApplication] endIgnoringInteractionEvents]; }