0

我试图在键盘隐藏之前收到通知。我已经尝试过可用的通知,但它们似乎都在键盘从屏幕上消失时调用。我需要在键盘开始向下滑动之前运行代码。

4

1 回答 1

1

观察通知:

[[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。

于 2013-06-14T22:35:57.153 回答