1

基本上我有3个步骤:

  1. 我需要准备要发送到服务器的数据。这需要一些时间。
  2. 准备好数据后,我必须将其发送到服务器——这也需要一段时间。
  3. 我等待服务器响应一切正常。

我正在考虑对这些操作中的每一个使用 MBProgressHUD - 我显示 hud,并使用该showWhileExecuting方法。然后,当我在该代码中隐藏 hud 时,我调用下一个操作,并再次显示 hud。

理论上这应该可行,但这是应该这样做的方式吗?

4

2 回答 2

2

最好不要依赖 MBProgressHUD。您应该将其用作用户的反馈元素,而不是作为运营经理。

例如,您可以使用 NSOperationQueue,并通知 hud 在每次迭代中更新其数据/状态。

当然,你可以像你说的那样使用它,但对我来说似乎并不干净(以编程方式)。

于 2012-07-10T14:05:26.523 回答
1

我在单击按钮时获得第一个动作,我使用这个:

    HUD = [[MBProgressHUD alloc] initWithWindow:[UIApplication sharedApplication].keyWindow];

        [self.view.window addSubview:HUD];


        // Regiser for HUD callbacks so we can remove it from the window at the right time
        HUD.delegate = self;

        // Show the HUD while the provided method executes in a new thread
        [HUD showWhileExecuting:@selector(DNS_info) onTarget:self withObject:nil animated:YES];

然后单击 2 个按钮,获取操作,如下所示:

HUD = [[MBProgressHUD alloc] initWithWindow:[UIApplication sharedApplication].keyWindow];

        [self.view.window addSubview:HUD];
//        HUD.dimBackground = NO;

        // Regiser for HUD callbacks so we can remove it from the window at the right time
        HUD.delegate = self;

        // Show the HUD while the provided method executes in a new thread
        [HUD showWhileExecuting:@selector(whois) onTarget:self withObject:nil animated:YES];

我想,这对你有帮助。

于 2012-07-10T14:22:30.707 回答