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.

+3
objective-c iphone uikit


source to share


No one has answered this question yet

Check out similar questions:

1665
How can I get the UITextField to move upward when there is a keyboard - when starting editing?
2
How to customize the pop-up menu on iPhone?
1
NSNotification issue for textbox and textbox
1
NSNotificationCenter notifications not received by UIView subclass
1
Capturing keystrokes with NSNotificationCenter
0
The button changes label.text; no prepareForSegue
0
Csrf token validation error for drupal services from iphone request
0
cancel keyboard when pressing any part of the view
0
The specific expression in the if condition causes a 7 second delay in execution
0
Changing views keeps giving me an attempt to represent vc1 to vc whose view is not in the window hierarchy



All Articles
Loading...
X
Show
Funny
Dev
Pics