The following function is a method of a class called TitleOverlay - which is a transparent overlay with a textView.
The function shows the overlay by animating its alpha, and in parallel uses the animationWillStart property of the animation to show the keyboard.
On 3G phones, the first time this function is called, there is some lag before the keyboard shows. In fact, I think the animation to show the overlay and show the keyboard are being serialized. I tried setting the length of the overlay alpha animation to various lengths, and the keyboad always shows after the animation completes.
Basically, the first time, there is lag. On all subsequent times, the keyboard and the overlay animations occur in parallel, and it looks nice.
WHat can I do to fix this?
- (void) showOverlay {
[[self superview] bringSubviewToFront:self];
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification
object:nil];
[nc addObserver:self
selector:@selector(keyboardWillHide:)
name:UIKeyboardWillHideNotification
object:nil];
[UIView beginAnimations:nil context: nil];
[UIView setAnimationDuration: .5];
[UIView setAnimationDelegate:titleField];
[UIView setAnimationWillStartSelector:@selector(becomeFirstResponder)];
self.whiteBlock.alpha = 1;
[UIView commitAnimations];
}