0

我两个单独工作都很好,但是当我尝试像这样组合它们时:

- (IBAction)showWithLabel:(id)sender 
{
    HUD = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];
    [self.checkinsViewController.view addSubview:HUD];
    HUD.delegate = self;
    HUD.labelText = @"Sending tweet";
    [HUD showWhileExecuting:@selector(tweet) onTarget:self withObject:nil animated:YES];
}

- (void)tweet { [_twEngine sendUpdate:@"Test tweet"]; }

我没有收到任何错误,但未发送推文如果我放置:

 [_twEngine sendUpdate:@"Test tweet"];

在 IBAction 中,它会发推文。如果我将推文更改为睡眠,HUD 会正确显示。

有任何想法吗?

4

1 回答 1

0

showHUDAddedTo:animated:showWhileExecuting:方法是互斥的。您不能同时使用这两种方法来显示 HUD 。

将您的初始化程序更改为仅分配一个 HUD,它应该可以工作。

HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
于 2011-06-17T16:40:38.830 回答