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;
//复原操作
}