MBProgressHUD block interface until operation is completed

I need to lock the interface until the MBProgressHUD operation is MBProgressHUD . I really referred to this topic,

Lock the interface until the operation is completed

Accordingly, we must disable each individual item that will not work for me. In my case, I need to disconnect the user from the "Back" button. I tried HUD.userInteractionEnabled = YES , which disables each controller except the back button. Is there a way to block a user from exiting this controller?

Respectfully,
Dilshan

+6
source share
4 answers

If you do not find the right way to do this, you can ignore all user interaction.

 [[UIApplication sharedApplication] beginIgnoringInteractionEvents]; 

.U can stop it on

 [[UIApplication sharedApplication] endIgnoringInteractionEvents]; 
+11
source

You can add MBProgressHUD to the navigation controller view so that it also prevents interaction with the back button:

 [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES]; 
+11
source

If you want a specific control to activate the HUD display, you can simply add the line [self.view bringSubviewToFront:yourControl]; into your showHUD method as

 -(void) showHUD:(UIView *)view { if (self.HUDdisplayed == NO) { self.HUDdisplayed = YES; HUD = [[MBProgressHUD showHUDAddedTo:self.view animated:YES] retain]; } // HUD.delegate = self; [self.view bringSubviewToFront:HUD]; [self.view bringSubviewToFront:yourControl]; } 
+4
source

This is how I add MBProgressHUD to my view and block all input until it is deleted:

 MBProgressHUD HUD = [[MBProgressHUD alloc] initWithView:self.view]; HUD.opacity = 0.7f; [self.view addSubview:HUD]; HUD.delegate = self; [HUD show:YES]; 

Note. self is the view controller that the HUD adds to

0
source

Source: https://habr.com/ru/post/920578/


All Articles