Search code examples
iphoneobjective-ciosipadmbprogresshud

performSelector: withObject: afterDelay not executing for MBProgressHUD


I have the following method for a MBProgressHUD:

 [progressHUD performSelector:@selector(hide:) 
                   withObject:[NSNumber numberWithBool:YES] 
                   afterDelay:kMessageHidingDelay];

the delay is 2.0 here, however it's not calling hide after 2.0 seconds. I tried to put a breakpoint in the hide function and it's not getting there. Any idea? Here's the full code:

progressHUD = [[MBProgressHUD alloc] initWithView:viewToAttach];

            // Add HUD to screen
            [viewToAttach addSubview:progressHUD];
            progressHUD.labelText = @"Logging In";
            progressHUD.removeFromSuperViewOnHide = YES;
            // Show the HUD while the provided method executes in a new thread

            [progressHUD show:YES];

Solution

  • May be try to perform selector on Main thread (all UI changes must be done on main thread)? performSelectorOnMainThread: