Note that there are some explanatory texts on larger screens.

plurals
  1. POShow activity indicator animation when button pressed
    text
    copied!<p>I have a button called "Sync". When tapped / pressed it sends data to a webserver and retrieves the answer by the server (what takes a while and freezes the gui / button) so how do I add a "Please wait" and activity indicator until the data / answer from the server arrives and the text / indicator is deleted and replaced by the answer from the server? </p> <p>This code freezes my app:</p> <pre><code>- (IBAction) syncButtonTapped { [syncButton setEnabled:NO]; //resultText.text= @"Bitte warten ..."; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *docDir = [paths objectAtIndex: 0]; NSString *docFile = [docDir stringByAppendingPathComponent: @"deck.txt"]; NSString *post = [NSString stringWithContentsOfFile:docFile encoding:NSUTF8StringEncoding error:nil]; NSString *post2 = [post stringByReplacingOccurrencesOfString:@"\n" withString:@","]; NSString *post3 = [post2 stringByReplacingOccurrencesOfString:@"\r" withString:@""]; NSString *post4 = [NSString stringWithFormat:@"{\"results\":[%@]}",post3]; NSString *urlString = [NSString stringWithFormat:@"http://storecheck.cortona.de/fetchresults.php?results=%@",[post4 stringByAddingPercentEscapesUsingEncoding: NSASCIIStringEncoding]]; NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease]; [request setURL:[NSURL URLWithString:urlString]]; [request setHTTPMethod:@"GET"]; NSString *data4 = @""; [data4 writeToFile: docFile atomically: NO encoding: NSUTF8StringEncoding error:nil]; //send request &amp; get response NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil]; NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding]; } </code></pre> <p>i am working on a Mac Mini with iOS 10.6.7</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload