1

对于 MBProgressHUD,我有以下方法:

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

这里的延迟是 2.0,但是在 2.0 秒后它不会调用 hide。我试图在隐藏函数中放置一个断点,但它没有到达那里。任何的想法?这是完整的代码:

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

3 回答 3

0

可以尝试在主线程上执行选择器(所有 UI 更改必须在主线程上完成)? performSelectorOnMainThread:

于 2012-01-10T22:06:22.023 回答
0

要显示 MBProgressHUD 使用此代码:-

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

也隐藏 MBProgressHud

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

如果你想用你的 CotomView 显示 Hud 然后使用这个代码

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

}

于 2012-01-11T05:28:35.230 回答
0

你必须隐藏MBProgressHud

[progressHUD hide:YES];
于 2012-01-11T05:33:28.913 回答