Bogdan Laukhin Bogdan Laukhin - 1 year ago 68
iOS Question

Keyboard for textfield appears after second tap (time to time)

I have one view in my app where there is 1 text field. And I've noticed that keyboard appears after second tap.

But it's interesting that on iPhone it's time to time (some time appears after first tap at once, and some time after second tap only).
On iPad looks like it more ofter appears after second tap only.

  • I use

  • in
    I assign the delegate
    _locationTextField.delegate = self;

  • and I use delegate methods


#pragma mark -
#pragma mark UITextFieldDelegate

- (void)textFieldDidBeginEditing:(UITextField *)textField {
_locationNameBeforeManualEdit = _locationTextField.text;
// save the previod city value to compare after did end editing


- (void)textFieldDidEndEditing:(UITextField *)textField{


- (BOOL)textFieldShouldReturn:(UITextField *)textField {
[self continueButtonPressed:nil];
// [textField resignFirstResponder];
return YES;

in storyboard
enter image description here

What could be the problem?

Answer Source

Found solution here on Stackoverflow - solution related with keyboard preload:

- (void)preloadKeyboard {
    UITextField *lagFreeField = [[UITextField alloc] init];
    [self.window addSubview:lagFreeField];
    [lagFreeField becomeFirstResponder];
    [lagFreeField resignFirstResponder];
    [lagFreeField removeFromSuperview]; 

This method should be used in application: didFinishLaunchingWithOptions: method of AppDelegate.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download