i am playing around with MBProgressHUD. the worflow in the viewcontroller (tableview) goes like that:
1) IBAction gets called to switch between 2 different tables
2.1) function reloadAllMonth gets called (initializes an array with the data for the new table)
2.2) MBProgressHUD *HUD should be displayed
3) reloadAllMonth is finished
4) HUD should disappear
my current code:
-(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.
}
what happens:
-> function touchesbegan gets called
-> nothing happens for 3-4 seconds (loading time)
-> new table pops up
question: why does the HUD not show up? where did i go wrong ?
You can’t have both show and hide in the same thread, this is what I would do:
Also you can remove the ivar HUD, you are not using it.
And don’t forget to initialize isLoading in viewDidLoad to NO:
Good luck!