Pregunta

Tengo el siguiente método para un MBProgressHud:

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

El retraso es 2.0 aquí, sin embargo, no llama a Hide después de 2.0 segundos. Traté de poner un punto de interrupción en la función de ocultación y no está llegando allí. ¿Alguna idea? Aquí está el código completo:

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];
¿Fue útil?

Solución

¿Puede intentar realizar selector en el hilo principal (todos los cambios de interfaz de usuario deben realizarse en el hilo principal)? performSelectorOnMainThread:

Otros consejos

tienes que ocultar el MBProgressHud

[progressHUD hide:YES];

Para mostrar MBProgressHud, use este código:-

  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"
  }

Y también esconde el MBProgressHud

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

Y si desea mostrar HUD con su CostomView, use este código

   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];

}

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top