我有以下代码,它连接到 Web 服务并返回一个类别数组。
我正在为 SOAP Web 服务使用以下包装器:
..以及MBProgressHUD
活动指标的以下内容:
https://github.com/jdg/MBProgressHUD
我想要一个 HUD 进度指示器来指示它正在连接和获取结果。我目前正在使用MBProgressHUD
以达到预期的效果,但是我注意到它不能正常工作。tableView
在加载和显示my 中的实际单元格之前,进度指示器会消失。我也在MBProgressHUD
我的应用程序的不同区域使用,但通常每次我连接到 Web 服务来获取结果。
有人可以指导我如何修复以下代码以使其正常工作吗?我认为这可能与显示进度指示器后触发回调方法有关。不太确定如何MBProgressHUD
使用回调方法正确实现。
这是我“试图”让它发挥作用的可怕尝试。
- (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
}