Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

textFieldDidBeginEditing is called prematurely

I have an application in which I have to scroll up in case of the keyboard showing. to get the keyboard size, I'm registering the UIKeyboardWillShowNotification event like so:

   [[NSNotificationCenter defaultCenter]
     addObserver:self
     selector:@selector(keyboardWillShow:)
     name:UIKeyboardWillShowNotification
     object:self.view.window]

This does work, the problem is, it is being called after the textFieldDidBeginEditing was called. So, I can't get the actual keyboard size, but only after the field is already in edit mode, which defeats the whole purpose of registering this event on the first place. I'm sure I've called the UIKeyboardWillShowNotification and not the UIKeyboardDidShowNotification, although switching these two yield the same results: first call was made to the delegate method and only then to the notification method. Any idea on how to turn this around? Currently I'm hard coding the size, which is very bad practice...

like image 782
donald Avatar asked Nov 12 '12 14:11

donald


1 Answers

May I suggest a GitHub repository

https://github.com/hackiftekhar/IQKeyboardManager

like image 51
Warif Akhand Rishi Avatar answered Oct 01 '22 04:10

Warif Akhand Rishi