MBProgressHUD在另一个线程中工作时崩溃了应用程序

时间:2013-10-02 07:23:37

标签: iphone ios nsthread mbprogresshud

我正在尝试在我正在使用MBProgressHUD的线程中做一些工作。当我尝试执行以下代码时,它会崩溃。

if ([database databaseNeedsMigration]) {
HUD = [[MBProgressHUD alloc] initWithView:self.view];
HUD.labelText = @"Upgrading Data";
HUD.detailsLabelText = @"Just relax";
HUD.mode = MBProgressHUDModeAnnularDeterminate;
[self.view addSubview:HUD];
HUD.taskInProgress = YES;
[[UIApplication sharedApplication] beginIgnoringInteractionEvents];
[HUD showAnimated:YES whileExecutingBlock:^{
[database migrateDatabase];
} onQueue:dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0) completionBlock:^{
     [[UIApplication sharedApplication] endIgnoringInteractionEvents];

     }];


}

然而,当我尝试将一个选择器添加到MBProgressHUD并在其运行的函数中进行休眠时。

0 个答案:

没有答案