title: xcode viewcontroller hiding fields not working
body: <p>I have a view controller with labels, textfields, activity indicator and a button control all tied with IBOutlets and accessible from within my code.</p>
  
  <p>When the user presses the button, I hide a few of the fields, and put up the activity indicator. I then make a synchronous URL call to get some JSON data.</p>
  
  <p>The view controller is not updated to reflect the activity indicator and hidden fields until AFTER the synchronous request returns. I need this to happen before the request returns so the users sees that something is happening.</p>
  
  <p>I have tried putting in a usleep(200000);, and also tried [self.view setNeedsDisplay]; - - both to no avail.</p>
  
  <p>Is there any way I can force the screen update BEFORE the blocking synchronous call? I know I can go to an async call, but I really don't want to do that since I cannot do anything in the app until/unless I get the data i need...</p>
  
  <p>Thanks,
  Jerry</p>
  
  <p>here is the code I use to send the sync request: This is the relevant portion of the routine 'SendGetEventsRequest'.</p>
  
  <pre><code>NSURLResponse *response = nil;
  NSError *error = nil;
  [self.aiActivityIndicator startAnimating];
  NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&amp;response error:&amp;error];
  </code></pre>
  
  <p>Here are the other routines i use right before the above routine gets called:</p>
  
  <pre><code>- (IBAction)btnGetEvents:(id)sender {
  // The user presssed the GetEvents button. Send the requested server to be processed.
  [self.aiActivityIndicator startAnimating];
  [self.lblCollectingEventNames setHidden:NO];
  [self.lblEnterServerName setHidden:YES];
  [self.btnGetEvents setHidden:YES];
  [self.tfServerName setHidden:YES];
  [self.view setNeedsDisplay];
  
  [self SendGetEventsRequest:self.tfServerName.text];
  }
  
  - (BOOL)textFieldShouldReturn:(UITextField *)textField{
  [self.tfServerName resignFirstResponder];
  [self btnGetEvents:self];
  return YES;
  }
  </code></pre>
  
  <p>Basically, when the user presses the 'go' button on the keyboard, the routine textFieldShouldReturn gets called. I dismiss the keyboard then simulate pushing the button 'Get Events'.</p>
  
  <p>In btnGetEvents, I start up the activity indicator, hide/show a few fields, then call sendGetEventsRequest. In there is the code where i do the Sync call.</p>
  
  <p>I am setting up the activity indicator and show/hide fields BEFORE the sync call, yet they are not updated until AFTER the sync call returns.  I believe this is because the view controller did not perform a screen redraw before the Sync call got executed.</p>
  
  <p>So, I need to figure out how to get the screen to update BEFORE the Sync call. I hope the additional code and additional explanation helps.</p>