iphone – 动态获取键盘的框架

是否有可能动态获取框架,实际上是键盘的高度?由于我有一个UITextView,我想根据键盘框架的高度,当键盘的输入法改变时调整其高度。因为你知道不同的输入法可能有不同的键盘框架高度。
尝试这个:

[[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..........
}

Tutorial for more information

http://stackoverflow.com/questions/11989306/get-the-frame-of-the-keyboard-dynamically

本站文章除注明转载外,均为本站原创或编译
转载请明显位置注明出处:iphone – 动态获取键盘的框架