title: resignFirstResponder with subsequent processing problems (keyboard dismiss blocked or crash on iPhone 5)
body: <p>I have the following workflow:</p>
  
  <pre><code>Input in Textfield -&gt; (Return key of TextField pressed: resignFirstResponder, IBAction of Button called) -&gt; IBAction of Button: perform an intensive operation
  </code></pre>
  
  <p>The problem is that the intensive operation is started before the Keyboard is dismissed with <code>resignFirstResponder</code>. As in other posts suggested (e.g. <a href="https://stackoverflow.com/a/3452767/1685971">https://stackoverflow.com/a/3452767/1685971</a>) I tried to use:</p>
  
  <pre><code>- (BOOL)textFieldShouldReturn:(UITextField *)textField {
      [textField resignFirstResponder];
      [self performSelector:@selector(ibActionMethod:) withObject:sender afterDelay:someTime];
      return YES;
  }
  </code></pre>
  
  <p>This works fine in simulator or on iPhone 4 but leads to a crash running on iPhone 5 (what I cannot understand, because I didn't use <code>performSelectorInBackground:withObject:</code>):</p>
  
  <pre><code>void _WebThreadLockFromAnyThread(bool): Obtaining the web lock from a thread other than the main thread or the web thread. UIKit should not be called from a secondary thread.
  bool _WebTryThreadLock(bool): Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now...
  </code></pre>
  
  <p>Another option I tried is to wait for resignFirstResponder in main thread with</p>
  
  <pre><code>[textField performSelectorOnMainThread:@selector(resignFirstResponder) withObject:nil waitUntilDone:YES];
  </code></pre>
  
  <p>But with this the keyboard is still not dismissed immediately (probably because the method waits only for the return of the selector <code>resignFirstResponder</code> and not for the finishing of the keyboard animation.</p>
  
  <p>Is there any solution to this?</p>