HUD Spinner没有出现

时间:2012-03-09 06:56:26

标签: objective-c ios mbprogresshud

我正在使用MBPROGRESSHUD为我的应用程序实现微调器和自定义视图。代码片段(在我的加载器类中)如下所示:

- (void)postObjects:(NSDictionary*) params andImage:(NSData *)img
{
    .....

    //THIS IS THE PART WHICH CALLS THE HUD
    [self performSelector:@selector(showLoading) withObject:nil afterDelay:0];
    [objectLoader send];
}


- (void) showLoading
{
    //CODE TO TRIGGER HUD SPINNER WITH LABEL
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:viewToShowLoading animated:YES];
    NSString * postingMsg = @"Pinning Question";
    hud.labelText = postingMsg;
}

- (void)objectLoader:(RKObjectLoader*)objectLoader didLoadObjects:(NSArray*)objects 
{
    //THIS IS THE PART WHERE THE HUD IS HIDDEN
    [MBProgressHUD hideHUDForView:viewToShowLoading animated:YES];

    //THIS IS WHERE I WANT TO DISPLAY THE CUSTOM VIEW WITH THE TEXT "QUESTION PINNED"
    self.HUDText = @"Question Pinned";
    [self performSelector:@selector(showCompleteHUD) withObject:nil afterDelay:0];
}

- (void) showCompleteHUD
{
    //CODE TO TRIGGER CUSTOM VIEW DISPLAY
    HUD = [[MBProgressHUD alloc] initWithView:viewToShowLoading];
    [viewToShowLoading addSubview:HUD];
    [HUD showWhileExecuting:@selector(customHUDComplete) onTarget:self withObject:nil   animated:YES];

}

- (void)customHUDComplete
{
    HUD.customView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"37x-Checkmark.png"]] autorelease];
    HUD.mode = MBProgressHUDModeCustomView;
    HUD.labelText = self.HUDText;
    sleep(2);
}

上面代码的问题是,在第一次显示HUD微调器之后,后续执行不会导致显示HUD微调器,而只是跳过显示自定义视图

enter image description here

这是一个时间问题(异步问题)吗?如果是这样,我如何确保在自定义视图出现之前始终显示微调器?

0 个答案:

没有答案