我正在玩MBProgressHUD。在的ViewController(tableview中)的worflow是這樣認爲:MBProgressHUD不會顯示
1)IBAction爲被調用,以2頁不同的表 2.1)功能reloadAllMonth
之間切換被調用(初始化與新表中的數據) 2.2)MBProgressHUD陣列* HUD應顯示 3)reloadAllMonth完成 4)HUD應該消失
我當前的代碼:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
//sparing you the code that determins where the tap occured
HUD = [[MBProgressHUD alloc]initWithFrame:self.view.frame];
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
[self reloadAllMonth];
allMonthIsActive = YES;
[MBProgressHUD hideHUDForView:self.view animated:YES];
// some other code table reload etc.
}
會發生什麼:
- >功能的touchesBegan被稱爲 - >什麼也沒有發生3-4秒(加載時間) - >新表彈出
問題:爲何HUD顯示不出來?我哪裏做錯了 ?
我改變了我的代碼給你的建議,但它沒有改變任何東西。 HUD仍然不會顯示。我更新了問題代碼到新的。 – 2012-03-24 14:47:19
回答評論 – Zalykr 2012-03-24 15:25:26
這是我絕對的第一個想法和代碼。問題是:reloadAllMonth方法然後在backgroundthread中執行。因此主線程運行並開始繪製tableview。 tableview需要我在reloadAllMonth中加載的數據。所以表開始繪製數據之前,因此它的應用程序崩潰=) – 2012-03-24 15:45:17