如何获得键盘大小调整UITextView和如何使用UIKeyboardFrameEndUserInfoKey与日本键盘?

如何获得一个键盘大小调整UITextView和如何使用UIKeyboardFrameEndUserInfoKey与日本键盘? 下面的代码来调整UITextView在标准键盘上工作良好。 但是不适用于日语。 如何解决它?

 - (void)keyboardWillShow:(NSNotification *)aNotification { [self moveTextViewForKeyboard:aNotification up:YES]; } - (void)keyboardWillHide:(NSNotification *)aNotification { [self moveTextViewForKeyboard:aNotification up:NO]; } - (void) moveTextViewForKeyboard:(NSNotification*)aNotification up: (BOOL) up { NSDictionary* userInfo = [aNotification userInfo]; // Get animation info from userInfo NSTimeInterval animationDuration; UIViewAnimationCurve animationCurve; CGRect keyboardEndFrame; [[userInfo objectForKey:UIKeyboardAnimationCurveUserInfoKey] getValue:&animationCurve]; [[userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] getValue:&animationDuration]; [[userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] getValue:&keyboardEndFrame]; // Animate up or down [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:animationDuration]; [UIView setAnimationCurve:animationCurve]; CGRect newFrame = textView.frame; CGRect keyboardFrame = [self.view convertRect:keyboardEndFrame toView:nil]; newFrame.size.height -= keyboardFrame.size.height * (up? 1 : -1); textView.frame = newFrame; [UIView commitAnimations]; } 

非常感谢您的帮助!

代码的正确的片段:

 CGRect newFrame = editSource.frame; CGRect keyboardFrame = [self.view convertRect:keyboardEndFrame toView:nil]; keyboardFrame.size.height -= tabBarController.tabBar.frame.size.height; if (up) { editHeight = newFrame.size.height; newFrame.size.height -= keyboardFrame.size.height; } else { newFrame.size.height = editHeight; } editSource.frame = newFrame; 

WARNIGN!

该方法已过时。 正确的答案在这里: 如何在iOS 7上添加对UITextView的中文键盘支持?