5

I'm using this MBProgressHUD code:

  MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
  hud.mode = MBProgressHUDModeText;
  hud.removeFromSuperViewOnHide = YES;
  [hud hide:YES afterDelay:1];

For the period that the HUD is being shown interactions with an UIScrollview (that contains the button this is called from) are disabled. I can't click on other buttons, or scroll the UIScrollview.

Why is MBProgressHUD blocking my interactions with the UIScrollview and how can I disable it?

MB.
  • 4,167
  • 8
  • 52
  • 79
  • MBProgressHUD is used when you are performing tasks that you need to wait for. It's supposed that you don't need to interact with anything until the process is finished. Anyway, are you firing your task on another thread?. MBProgressHUD should be in the main thread and the task you want to run must be on another thread. – Teofilo Israel Vizcaino Rodrig May 14 '12 at 21:04
  • It's simpler than that, I just want to display a short notice when a button has been tapped. But people might want to switch the buttons before the animation dissapears. – MB. May 14 '12 at 22:02

3 Answers3

17

I'm using MBProgressHUD version 0.5 and simply set:

HUD.userInteractionEnabled = NO;

With this allow user interaction in parent view.

hernan
  • 383
  • 3
  • 8
0

maybe because the buttons are in the same view what you are trying to add the progress view and when the progress view is in view this view blocks the view what the buttons are added.

NTTake
  • 406
  • 1
  • 3
  • 19
0

MBPregressHUD blocks the interaction in below method

-(void)show:(BOOL)animated{
    [[UIApplication sharedApplication] beginIgnoringInteractionEvents];
    ...
    ...
    ...
}

This line of code blocks all of the interactions inside your application. If you do want to keep the interactions, drive it through a class level BOOL, you can call it isModal and decide if you want to block the interactions or not

 -(void)show:(BOOL)animated{
      if(isModal){
        [[UIApplication sharedApplication] beginIgnoringInteractionEvents];
      }
      ...
      ...
      ...
  }

Ideally you should create a new 'init' method to take this BOOL as parameter. Possible signature could be

- (id)initWithView:(UIView *)view isModal:(BOOL)modal;

and then initialize the class level BOOL inside this method after initializing the view. The same condition should be applied in the 'hide' method.

Happy coding... :)

Ziya
  • 81
  • 1
  • 6
  • 1
    Maybe this was a possible solution for this problem, however at the time of this post, the implementation of MBProgressHUD;s show method doesn't call 'beginIgnoringInteractionEvents' anymore, but blocks the UI anyway. I GUESS this is because MBProgressHUD is a subclass of UIView that doesn't implement any Event handling methods (i.e. touchesBegan/Moved/Ended/Cancelled), thus breaking the responder chain. – Tafkadasoh Mar 19 '13 at 19:40