iOS 11 - 键盘高度在键盘通知中返回0 [英] iOS 11 - Keyboard Height is returning 0 in keyboard notification
本文介绍了iOS 11 - 键盘高度在键盘通知中返回0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在使用键盘通知,没有任何问题,并获得精确的键盘高度。
I have been using Keyboard notifications without any problem and getting exact height of Keyboard.
- (void)keyboardDidShow:(NSNotification *) notification{
CGSize keyboardSize = [[[notification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
NSLog(@"%f",keyboardSize.height);}
但是在iOS 11中,调用通知时键盘的大小为0。
but with iOS 11 the size of keyboard is 0 when the notification is called.
此方案中出现的问题是什么?我正在使用xcode 9 Beta 5
What is the problem occurring in this scenario? I am using xcode 9 Beta 5
推荐答案
使用此:
CGSize keyboardSize = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
对于Swift,您可以使用:
For Swift, you can use:
let keyboardSize = (notification.userInfo![UIKeyboardFrameEndUserInfoKey] as! NSValue).cgRectValue.size
这篇关于iOS 11 - 键盘高度在键盘通知中返回0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文