我的要求是当从 JSON 中检索数据时,我需要显示活动指示器,但数据检索仅以一种方法执行。这意味着例如,当我单击按钮时,它会从 JSON 中检索数据并在表视图中显示该表视图存在于另一个视图控制器中。这里我的情况是当用户单击按钮时我需要检索数据并导航到下一个视图。当数据检索时我需要显示活动指示器。
-(void)searchBtnActn {
[self.webViewActivityIndicator setHidden:NO];
[self.view addSubview:webViewActivityIndicator];
[self.view bringSubviewToFront:webViewActivityIndicator];
[webViewActivityIndicator startAnimating];
if ([textField.text intValue] > 0)
{
AppDelegate *sharedDelegate = [[UIApplication sharedApplication]delegate];
sharedDelegate.textFldData = textField.text;
DealerLocationMapViewController *dealerLocationObj = [[DealerLocationMapViewController alloc]initWithNibName:@"DealerLocationMapViewController" bundle:nil];
dispatch_queue_t queue = dispatch_get_global_queue(
DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(queue, ^{
[dealerLocationObj searchBtnmethod:textField.text];
[webViewActivityIndicator performSelectorOnMainThread:@selector(stopAnimating) withObject:nil waitUntilDone:YES];
});
[self.navigationController pushViewController:dealerLocationObj animated:YES];
[dealerLocationObj release];
}