Search code examples
iphoneiosmbprogresshud

Why MBProgressHUD not show, when an alert show before HUD show?


I use this code to init MBProgressHUD

    UIWindow *window = [[UIApplication sharedApplication] keyWindow]  
    _hud = [[MBProgressHUD alloc]initWithWindow:window];
    _hud.dimBackground = bDim;
    _hud.labelText = message;
    [window addSubview:_hud];
    [_hud show:YES];

but sometimes _hud not show in window ? Anyone let me know where im lack here?? Thanks!


Solution

  • Click here! This works for me .Just use this window.

    UIWindow *keyWindow = [[[UIApplication sharedApplication] delegate] window];
    

    Or you can use

    self.navigationController.view 
    

    to add you HUD.