简体   繁体   中英

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.

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM