我试图在我的主线程的 tableview 控制器的子视图中显示微调器。该视图仅偶尔显示,并且通常在我的后台线程完成后显示。这是我的代码:
[self.view addSubview:spinnerView];
[self.view bringSubviewToFront:spinnerView];
self.spinnerView.layer.cornerRadius = 8;
self.spinnerView.center = CGPointMake(160, 150);
[spinner startAnimating];
dispatch_queue_t downloadQueue = dispatch_queue_create("downloader", NULL);
dispatch_async(downloadQueue, ^ {
dispatch_async(dispatch_get_main_queue(), ^{
[NSThread sleepForTimeInterval:10];
// Add recurring transactions if necessary
if (tran.recur.id != 0) {
[Utilities addRecurringTransactionsUpToCurrentMonthByTransaction:tran];
}
[spinner stopAnimating];
[self dismissViewControllerAnimated:YES completion:nil];
});
});
dispatch_release(downloadQueue);
}
}