I'm using AFnetworking to make a call to a server. While downloading I am using MBProgressHUD to show that data is being downloaded. So far everything works great. My issue is when I press the home button and then relaunch the app. I would like for the page to automatically refresh itself and for MBProgressHUD to display to the user that something is being downloaded. That I cannot do. I can download the data, but I cannot get the HUD part to work.
First, in the viewDidLoad Method I add this:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationDidBecomeActiveNotificationAction)
name:UIApplicationDidBecomeActiveNotification
object:nil];
Now in the method applicationDidBecomeActiveNotificationAction
, I call [self downloadWebsites]
.
In the method downloadWebsites
is where the bulk of the work is done: Here it is:
//show the hud
MBProgressHUD* progressHUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
progressHUD.labelText = @"Loading";
progressHUD.mode = MBProgressHUDAnimationFade;
[self.list_websites getPath:[NSString stringWithFormat:@"%@?%@", @"websites", self.auth_header] parameters: nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
//download data in the success block
//refresh the ui
[self.tableView reloadData];
[progressHud self.view animated:YES];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
//failure block. log the error
NSLog([error description]);
}];
Why doesn't this work? I can get the data. But I can't get the progressHud to display. How do I fix this?