Note that there are some explanatory texts on larger screens.

plurals
  1. POGet keyboard size without UIKeyboardWillShowNotification
    text
    copied!<p>I want to get the size of the keyboard without using the keyboard notifications available. The reason is I have several text field on the view and I don't need to resize the view for <strong>all</strong> of them, as I have seen in nearly every example. I just need to resize the view for some of the text fields/views that will be <strong>behind</strong> the keyboard when editing. So I'm using <code>textFieldDidBeginEditing</code> and <code>textFieldDidEndEditing</code> methods, because here I know what textfield is being edited. Another problem is that even if I subscribe to the keyboard notifications the <code>UIKeyboardWillShowNotification</code> is fired after <code>textFieldDidBeginEditing</code> so I cannot get the keyboard size on the first activation. I assume no information is provided from the keyboard notification functions where the actual text field or view is abailable.</p> <pre><code>The following code works but I need the keyboard size: - (void) textFieldDidBeginEditing:(UITextField *) textField { if ([theControls containsObject: textField]) { [UIView beginAnimations: @"szar" context: nil]; [UIView setAnimationDuration:0.3]; self.view.transform = CGAffineTransformTranslate(self.view.transform, 0, -216); [UIView commitAnimations]; } } - (void) textFieldDidEndEditing:(UITextField *) textField { if ([theControls containsObject: textField]) { [UIView beginAnimations: @"szar" context: nil]; [UIView setAnimationDuration:0.3]; self.view.transform = CGAffineTransformTranslate(self.view.transform, 0, +216); [UIView commitAnimations]; } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload