Track keyboard position in iOS 5 with unlocked / split keyboard
I have a view that needs to be exactly on the keyboard, but I am not using a UITextView, so I cannot use inputAccesoryView.
Anyway, before iOS 5 I had no problem, the problem is with the unlocked / split keyboard. Now I have to listen for changes in the keyboard frame with UIKeyboardWillChangeFrameNotification, so I do
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyFrameChanged:)
name:UIKeyboardWillChangeFrameNotification
object:self.view.window];
So, once the keyboard has been moved, the result is this:
- (void) keyFrameChanged:(NSNotification *)notification
{
NSDictionary* userInfo = [notification userInfo];
CGRect keyboardEndFrame;
[[userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] getValue:&keyboardEndFrame];
// Animate view with keyboardEndFrame data
}
The problem is that 99% of the time, UIKeyboardFrameEndUserInfoKey returns null, so I have no clue about the keyboard position.
Thank!
PS: I was able to bind the view as inputAccesoryView by overriding this property in my UIResponder subclass (not read-only anymore), but I still want to know how to keep track of the keyboard frame.
source to share
No one has answered this question yet
Check out similar questions: