是否可以动态获取键盘的框架,实际上是它的高度?由于我有一个 UITextView
并且我想在更改键盘输入法时根据键盘框架高度调整其高度.如您所知,不同的输入法可能有不同的键盘框架高度.
Is it possible to get the frame, actually its height, of the keyboard dynamically? As I have a UITextView
and I would like to adjust its height according to the keyboard frame height, when the input method of the keyboard is changed. As you know, different input methods may have different keyboard frame height.
试试这个:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWasShown:)
name:UIKeyboardDidShowNotification
object:nil];
- (void)keyboardWasShown:(NSNotification *)notification
{
// Get the size of the keyboard.
CGSize keyboardSize = [[[notification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
//Given size may not account for screen rotation
int height = MIN(keyboardSize.height,keyboardSize.width);
int width = MAX(keyboardSize.height,keyboardSize.width);
//your other code here..........
}
教程了解更多信息
这篇关于动态获取键盘边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!