键盘自动校正高度(有/无自动校正)

时间:2015-05-25 07:58:56

标签: ios iphone uitextfield uitextview uikeyboard

我得到的键盘高度如下:

- (void)keyboardNotification:(NSNotification*)notification
{
    NSDictionary* keyboardInfo = [notification userInfo];
    NSValue* keyboardFrameBegin = [keyboardInfo valueForKey:UIKeyboardFrameEndUserInfoKey];
    CGRect keyboardFrameBeginRect = [keyboardFrameBegin CGRectValue];
}

现在,我有键盘高度。 但没有自动修正高度:

enter image description here

如果UITextAutocorrectionTypeYES / NO,则键盘高度保持不变。

如何获得键盘自动校正高度?

提前致谢。

2 个答案:

答案 0 :(得分:3)

使用此:

 CGRect keyboardBounds;
        [[notification.userInfo valueForKey:UIKeyboardFrameEndUserInfoKey] getValue: &keyboardBounds];
   // Need to translate the bounds to account for rotation.
  keyboardBounds = [self.view convertRect:keyboardBounds toView:nil];

答案 1 :(得分:0)

使用NSConcreteNotification 0xc472900 {name = UIKeyboardWillChangeFrameNotification; userInfo = { UIKeyboardAnimationCurveUserInfoKey = 7; UIKeyboardAnimationDurationUserInfoKey = "0.25"; UIKeyboardBoundsUserInfoKey = "NSRect: {{0, 0}, {320, 216}}"; UIKeyboardCenterBeginUserInfoKey = "NSPoint: {160, 588}"; UIKeyboardCenterEndUserInfoKey = "NSPoint: {160, 372}"; UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0, 480}, {320, 216}}"; UIKeyboardFrameChangedByUserInteraction = 0; UIKeyboardFrameEndUserInfoKey = "NSRect: {{0, 264}, {320, 216}}"; }} 。每当建议栏显示或隐藏时,都会调用此方法。

{{1}}