iOS8 UIKeyboardWillShowNotification 键盘遮挡问题

iOS8中,键盘呼出会发送UIKeyboardWillShowNotification两次通知,导致在做键盘遮挡问题的时候会减两遍键盘的高度,原因如下:

The reason is the difference in the keyboard. If the second field is a password field this means there is another keyboard under the hood. Therefore the notification is sent twice.

解决方法:

@property(nonatomic, assign) BOOL kbIsOn;

/*

* 注册键盘的通知addObserver

*/

-(void)keyboardWillShow:(NSNotification *)noti

{

  if(!_kbIsOn)

  {

    //遮挡操作  

  }

  _kbIsON = YES;

}

 

-(void)keyboardWillHidden

{

  _kbIsOn = NO;

  //复原操作

}

posted @ 2015-09-30 14:46  Vick-Jo  阅读(240)  评论(0编辑  收藏  举报