In iOS 6 I'm used to present keyboard in viewDidLoad
.
- (void)viewDidLoad
{
[super viewDidLoad];
[txtField becomeFirstResponder];
}
This way, when navigationController pushes the new viewController, keyboard is already there, animating smoothly from left to right and avoiding bottom-up animation.
In iOS 7 this behavior seems broken.
If I add [txtField becomeFirstResponder]
in viewDidLoad
, keyboard appears in the middle of pushing animation, already in its final position: an unpleasant effect!!
I've tried to move [txtField becomeFirstResponder]
in viewWillAppear
, but the final result is unchanged.
Do you know a way to get back iOS 6 behavior, pushing the new viewController and the keyboard all together?
EDIT: Using a timer doesn't work either... whatever time delay I set, the keyboard is shown only at the end of pushing animation.
So far, my best try it is to put [txtField becomeFirstResponder]
in viewWillLayoutSubviews
or viewDidLayoutSubviews
. Unfortunately, doing so working when pushing viewController but not when popping back (the keyboard doesn't appear).
I've managed to extrapolate your workaround in viewWillLayoutSubviews
to force it to work.
- (void)viewWillLayoutSubviews {
if (![self.textField1 isFirstResponder] && ![self.textField2 isFirstResponder] && ...) {
[self.textField1 becomeFirstResponder];
}
}
This is working for me for both pushing onto the stack, and after dismissing a modal view controller.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With