jdg / MBProgressHUD

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

Hud is not actually removed form superview when call [hud hideAnimated:YES afterDelay:2.0]; #566

Closed magic3584 closed 5 years ago

magic3584 commented 5 years ago

I wanna make a toast with a macro like this:

#define showToast(msg) [MyHudView showMessage:msg forView:self.view animation:YES];

+ (void)showMessage:(NSString *)message forView:(UIView *)view animation:(BOOL)animation {
    MBProgressHUD *hud = [[MBProgressHUD alloc]init];
    [view addSubview:hud];
    //
    hud.label.text = message;
    hud.label.numberOfLines = 0;
    hud.bezelView.backgroundColor = [UIColor blackColor];
    [hud setMode:MBProgressHUDModeText];
    hud.bezelView.layer.cornerRadius = 30.0;
    hud.label.textColor = [UIColor whiteColor];
    //
    [hud showAnimated:animation];
    [hud hideAnimated:animation afterDelay:2.0];
}

I use it in UIViewController like this:

showToast(@"some message");

It is visually removed but not actually while using Xcode debug hierarchy :

Imgur

Thanks for your help

matej commented 5 years ago

You need to manually remove it or set https://github.com/jdg/MBProgressHUD/blob/202d8895c6eb10ead2e4b3c5837a68c95693d51f/MBProgressHUD.h#L208

magic3584 commented 5 years ago

@matej Appreciate for your instruction, thx~