我正在尝试在键盘即将显示时收到通知,但目前它正在显示键盘后触发。
这是我的通知注册:
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector (keyboardDidShow:)
name: UIKeyboardDidShowNotification
object:nil];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector (keyboardDidHide:)
name: UIKeyboardDidHideNotification
object:nil];
答案 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