键盘通知未正确触发

时间:2014-09-04 15:45:23

标签: iphone

我正在尝试在键盘即将显示时收到通知,但目前它正在显示键盘后触发。

这是我的通知注册:

[[NSNotificationCenter defaultCenter]
     addObserver:self
     selector:@selector (keyboardDidShow:)
     name: UIKeyboardDidShowNotification
     object:nil];
[[NSNotificationCenter defaultCenter]
     addObserver:self
     selector:@selector (keyboardDidHide:)
     name: UIKeyboardDidHideNotification
     object:nil];

1 个答案:

答案 0 :(得分:1)

尝试使用:

[[NSNotificationCenter defaultCenter]
     addObserver:self
     selector:@selector (keyboardDidShow:)
     name: UIKeyboardWillShowNotification
     object:nil];
[[NSNotificationCenter defaultCenter]
     addObserver:self
     selector:@selector (keyboardDidHide:)
     name: UIKeyboardWillHideNotification
     object:nil];

UIKeyboardDidShowNotification更改为UIKeyboardWillShowNotification