0
當我從第二個視圖返回到我的mainView時,我正在處理我的第二個視圖的viewDidDisappear方法中的某些內容。問題是,我的mainView由於應用程序必須做的工作而卡住了。即使我使用GCD,用戶界面也會卡住
這裏是我做的:
-(void)viewDidDisappear:(BOOL)animated
{
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul);
dispatch_async(queue, ^{
dbq = [[dbqueries alloc] init];
[[NSNotificationCenter defaultCenter] postNotificationName:@"abc" object:nil];
//the notification should start a progressView, but because the whole view gets stuck, I can't see it working, because it stops as soon as the work is done
dispatch_sync(dispatch_get_main_queue(), ^{
//work
});
});
我在做什麼錯? 在此先感謝!
沒有,問題是他做的主線程上的工作。 – 2012-07-18 12:44:42
視圖仍然卡住,沒有加載指示器 – oybcs 2012-07-18 12:44:57
所以我必須創建另一個線程?但是,我必須使用這個GCD thingy嗎?因爲,如果它在另一個線程上,爲什麼我需要這個? – oybcs 2012-07-18 12:46:50