The best place to add this view is AppDelegate
. Add view in to appDelegate window will show to top front for whole application. Also it remains on top until you hide or remove this view from appDelegate window.
Create a global object of MBProgressHUD
in AppDelegate
class and create show/hide methods.
Call this methods respectively for your convenience use.
For Example:
@property (nonatomic, strong) MBProgressHUD *hud;
- (void) showProgress:(NSString *)message {
// Create a loading view
if (!self.hud) {
_hud = [MBProgressHUD showHUDAddedTo:fronMostView animated:YES];
self.hud.mode = MBProgressHUDModeText;
// Add Progress to window.
[self.window addSubview:self.hud];
}
self.hud.hidden = NO;
self.hud.labelText = [Localization localize:message];
}
- (void) hideLoadingMessage {
self.hud.labelText = [Localization localize:@"Finished!"];
[self.hud hide:YES afterDelay:1];
}