关于中文键盘的issue(About issue with Chinese Keyboard)

  当需要调用键盘时,有时会遮住输入框,我们一般都会将UITextField或UITextView向上移动,如下处理

1 1 CGRect textFieldFrame = self.textField.frame;
2 2 textFieldFrame.origin.y -=216;
3 3 self.textField.frametextFieldFrame;

  而216只是针对某些语言的键盘高度,当使用中文键盘时,它的高度是252,这样会遮住UITextField。

  因此我们在编程时需要判断键盘高度,而不是固定一个高度,下面将介绍如何获取各种输入语言的键盘高度

  获取键盘高度通知是在ios5后才有的,因此我们需要加入条件。

  

#ifdef __IPHONE_5_0
    float version = [[[UIDevice currentDevice] systemVersion] floatValue];
    if (version >= 5.0) {
        [notifyCenter addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillChangeFrameNotification object:nil];
    }
#endif
 1 -(void)keyboardWillShow:(NSNotification *)sender
 2 {
 3     if (!self.iKerboardIsShow) {
 4         NSDictionary *userInfo = [sender userInfo];
 5         self.iHeightOfKerboard = [[userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size.height;
 6         [self keyboardWillShowOrHideAnimation:YES];
 7         [self transparentviewWillAppear:nil];
 8           self.iKerboardIsShow = YES;
 9     }
10 }
原文地址:https://www.cnblogs.com/konglei/p/4830581.html