On a view I have a button linked to this method
In the php function called by this method I've put a 5 seconds pause to make it slow and see the activity indicator.
When I tap the button I can see the app wait the 5 seconds, but the indicator doesn't appear.
I've tried to remove the lines
[self.activityIndicator stopAnimating];
self.activityIndicator.hidden = TRUE;
going back to the main view the indicator is there spinning.
Why doesn't the indicator start as I tap the button, but after that the php function returns?
Code:
- (IBAction)performSearch:(id)sender {
self.activityIndicator.hidden = FALSE;
[self.activityIndicator startAnimating];
NSMutableURLRequest *richiesta = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://www.sito.it/iosphp/responder.php"]
cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:120.0];
[richiesta setHTTPMethod:@"POST"];
[richiesta setHTTPBody:[[NSString stringWithFormat:@"search=%@", self.textInput.text] dataUsingEncoding:NSASCIIStringEncoding]];
NSURLResponse *response;
NSError *error;
NSData *dati = [NSURLConnection sendSynchronousRequest:richiesta returningResponse:&response error:&error];
NSString *esitoRicerca = [[[NSString alloc] initWithData:dati encoding:NSASCIIStringEncoding] autorelease];
[self.activityIndicator stopAnimating];
self.activityIndicator.hidden = TRUE;
if ([esitoRicerca isEqualToString:@"nodata"]) {
self.labelEsito.text = @"Nessuna corrispondenza trovata";
}
else
{
self.labelEsito.text = @"";
TableResultsViewController *table = [[TableResultsViewController alloc] init];
table.results = [esitoRicerca JSONValue];
[self.navigationController pushViewController:table animated:YES];
[table release];
}
}
When I tap the button I can see the app wait the 5 seconds, but the indicator doesn't appear.
I've tried to remove the lines
[self.activityIndicator stopAnimating];
self.activityIndicator.hidden = TRUE;
going back to the main view the indicator is there spinning.
Why doesn't the indicator start as I tap the button, but after that the php function returns?