我试图在键盘隐藏之前收到通知。我已经尝试过可用的通知,但它们似乎都在键盘从屏幕上消失时调用。我需要在键盘开始向下滑动之前运行代码。
最佳答案
观察通知:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
方法:
- (void)keyboardWillShow:(NSNotification *)notification {
}
- (void)keyboardWillHide:(NSNotification *)notification {
}
隐藏键盘需要 0.25 或 0.3。 如果您需要在隐藏之前执行操作,只需将计时器设置为 0.2,在完成操作之前您将有 0.1。
关于iphone - 键盘隐藏之前的通知?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17118230/