I am using the following SOAP web service wrapper:
http://www.sudzc.com/
.. and the following MBProgressHUD of activity indicators:
https://github.com/jdg/MBProgressHUD
p>
I want to have a HUD progress indicator to indicate that it is connecting and fetching results. I am currently using MBProgressHUD to achieve the desired effect, but I noticed that it does not work properly. In loading and displaying my tableView The progress indicator disappears before the actual cell. I also use MBProgressHUD in different areas of my application, but usually every time I connect to the web service to get the result.
Can anyone guide me how to Solve the following code to work properly? I think this may be related to triggering the callback method after the progress indicator is displayed. Not sure how to use the callback method to implement MBProgressHUD correctly.
This is my terrible attempt to “try” to make it work.
p>
- (void)showHUD {
HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
// Add HUD to screen.
[self.navigationController.view addSubview:HUD];
// Register for HUD callbacks so we can remove it from the window at the right time.
HUD .delegate = self;
HUD.labelText = @"Loading";
// Show the HUD while the provided method executes in a new thread
[HUD showWhileExecuting:@selector(runLocalNotificationHandler) onTarget:self withObject:nil animated:YES];
}
- (void)runLocalNotificationHandler {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[self performSelectorOnMainThread:@selector(connectToService) withObject:nil waitUntilDone:YES];
[pool release];
}
- (void)connectToService {
Service 1 *service = [[Service1 alloc] init];
[service GetCategories:self action:@selector(handlerGetCategories:)];
[service release];
}
< br />- (void)handlerGetCategories:(id)value {
// parse objects returned from array, populate array, reload table view data, etc
}
< /p>
MBProgressHUD *HUD = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];
Replace
HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
Then put the following in your callback method:
< pre>[MBProgressHUD hideHUDForView:self.navigationController.view animated:YES];
In this way, you can know exactly when to show and close the HUD. At least, by viewing the changes after using the new method , It will help you debug where the real problem is.
I have the following code, which connects to a web service and returns an array of Categories.
< p>I am using the following SOAP web service wrapper:
http://www.sudzc.com/
.. and the following MBProgressHUD for activity indicators:
< p>ht tps://github.com/jdg/MBProgressHUD
I want to have a HUD progress indicator to show that it is connecting and fetching results. I am currently using MBProgressHUD to achieve the desired effect, but I noticed It doesn’t work properly. The progress indicator disappears before the actual cell in my tableView is loaded and displayed. I also use MBProgressHUD in different areas of my application, but usually every time I connect to the web service to get the result.
Can someone guide me how to solve the following code to work properly? I think this may be related to triggering the callback method after the progress indicator is displayed. Not sure how to use the callback method to implement MBProgressHUD correctly.
This is my terrible attempt to “try” to make it work.
p>
- (void)showHUD {
HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
// Add HUD to screen.
[self.navigationController.view addSubview:HUD];
// Register for HUD callbacks so we can remove it from the window at the right time.
HUD .delegate = self;
HUD.labelText = @"Loading";
// Show the HUD while the provided method executes in a new thread
[HUD showWhileExecuting:@selector(runLocalNotificationHandler) onTarget:self withObject:nil animated:YES];
}
- (void)runLocalNotificationHandler {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[self performSelectorOnMainThread:@selector(connectToService) withObject:nil waitUntilDone:YES];
[pool release];
}
- (void)connectToService {
Service1 * service = [[Service1 alloc] init];
[service GetCategories:self action:@selector(handlerGetCategories:)];
[service release];
}
- (void)handlerGetCategories:(id)value {
// parse objects returned from array, populate array, reload table view data, etc
}
< /p>
If you use MBProgressHUD while executing callbacks, there is another way. Initialize the HUD before starting background processing
MBProgressHUD *HUD = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];
Replace
HUD = [[MBProgressHUD alloc] initWithView:self. navigationController.view];
Then put the following in your callback method:
[MBProgressHUD hideHUDForView:self.navigationController.view animated:YES ];
In this way, you can know exactly when to show and close the HUD. At least, by looking at the changes after using the new method, it will help you debug where the real problem is.