0

我在@interface ZxBancaD 中展示:UITableViewController 一个 MBProgressHUD,每次关闭模态视图时

- (void) disparaMa:(NSNotification *)notification {
   hudX                 = [MBProgressHUD showHUDAddedTo:self.splitViewController.view animated:YES];
   hudX.delegate        = self;
   hudX.mode            = MBProgressHUDModeAnnularDeterminate;
   hudX.labelText       = @"Pago Minimo...";
   hudX.dimBackground   = YES;
   [hudX showWhileExecuting:@selector(actEtiqueta) onTarget:self withObject:nil animated:YES];

   dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0), ^ (void) {
    [self miniAutomatico];
   });
}

我用这个方法来更新我的 hudX

- (void) actEtiqueta {
   xP                       = 0.0f;
   while (xP < 1) {
     xT                     = [[NSUserDefaults standardUserDefaults] integerForKey:kVueltas];
     xP                     = ((double)xT)/24;
     hudX.detailsLabelText  = [NSString stringWithFormat:@"Vuelta%i", xT];
     hudX.progress          = xP;
     NSLog(@"AxTiempoB.actEtiqueta.progress %f | xP %f | xT %i", hudX.progress, xP, xT);
     usleep(50000);
   }
}

后台进程为(此处计算xT变量):

- (void) miniAutomatico                                {
    cwMonitorBz                                    = [[[CwMonitorBz alloc] init]autorelease];
    cwMonitorBz.persistentStoreCoordinator         = self.persistentStoreCoordinator;
    cwMonitorBz.managedObjectContextp              = self.managedObjectContextp;
    cwMonitorBz.gmCuenta                           = gmCuenta;
    cwMonitorBz.esCuentaCero                       = @"1";
    [self.cwMonitorBz monitorMinimoAuto];

    dispatch_async(dispatch_get_main_queue(), ^{
        NSLog(@"acabo..miniAutomatico");
        [MBProgressHUD hideHUDForView:self.splitViewController.view animated:YES];
    });
}

由于某种原因,hudX 不会动态(实时)更新。它显示正确的值:来自后台进程的 (int) XT,但滞后。我猜我的主线程(UI)被阻塞了,但我不知道为什么或在哪里。

如何实时更新我的​​ hudX (UI)?非常感谢您的回复。

4

0 回答 0