我使用此代码来确定键盘的大小:
- (void)keyboardWillChange:(NSNotification *)notification {
NSDictionary* keyboardInfo = [notification userInfo];
NSValue* keyboardFrameBegin = [keyboardInfo valueForKey:UIKeyboardFrameBeginUserInfoKey];
CGRect keyboardFrameBeginRect = [keyboardFrameBegin CGRectValue];
}
Run Code Online (Sandbox Code Playgroud)
我在模拟器中运行它.
问题是,因为iOS 8这将不会给出正确的值,如果键盘建议已启动或者如果我将它们向下推,则会得到不同的(不正确的)值.
如何获得键盘的确切大小,包括键盘建议?