Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get third-party keyboard size in iOS 8?

I've installed Swift Keyboard in my phone 5s with iOS 8.

The original method (Objective-C) to obtain the keyboard size only works with the system keyboard, for example:

- (void)keyboardWillShow:(NSNotification *)notification
{
    CGSize keyboardSize = [[[notification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
}

If I use Swift Keyboard... keyboardSize.height is zero. How to get third-party keyboard size in iOS 8?

Thanks.

like image 519
Jorge SV Avatar asked Sep 18 '14 08:09

Jorge SV


1 Answers

I think that's because you're getting the size before the keyboard has actually been displayed.

Try replacing:

objectForKey:UIKeyboardFrameBeginUserInfoKey

With:

objectForKey:UIKeyboardFrameEndUserInfoKey

This is working for me with SwiftKey!

like image 166
mezan Avatar answered Sep 19 '22 16:09

mezan