문제

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];
도움이 되었습니까?

해결책

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

다른 팁

you have to hide the MBProgressHud

[progressHUD hide:YES];

To Show MBProgressHUD Use this Code:-

  HUD = [[MBProgressHUD alloc] init];

  [self.view addSubview:HUD];

  HUD.delegate = self;

  [HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES];

  where myTask is

   - (void)myTask 
  {
     "Your Code"
  }

And too Hide the MBProgressHud

 - (void)hudWasHidden:(MBProgressHUD *)hud
    {
       // Remove HUD from screen when the HUD was hidded
       [HUD removeFromSuperview];
       [HUD release];
   HUD = nil;
   }

And If you Want to Show Hud With Your CostomView Then Use This Code

   HUD = [[MBProgressHUD alloc] init];

[self.view addSubview:HUD];

// Make the customViews 37 by 37 pixels for best results (those are the bounds of the build-in progress indicators)
HUD.customView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Your Image Name.png"]] autorelease];

// Set custom view mode
HUD.mode = MBProgressHUDModeCustomView;

HUD.delegate = self;

HUD.labelText = @"Completed";

[HUD show:YES];

[HUD hide:YES afterDelay:3];

}

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top