5

如何UIKeyboard在我的应用程序中找到是否打开?

我不想使用任何委托方法UITextField

请提出任何解决方案。

提前致谢。

4

2 回答 2

5

测试这个:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
于 2013-03-05T08:47:19.340 回答
4

来自官方文档。

使用键盘通知检查状态UIKeyBoard

键盘通知:

当系统显示或隐藏键盘时,它会发布几个键盘通知。这些通知包含有关键盘的信息,包括其大小,您可以将其用于涉及移动视图的计算。注册这些通知是获取有关键盘的某些类型信息的唯一方法。系统为键盘相关事件提供以下通知:

UIKeyboardWillShowNotification
UIKeyboardDidShowNotification
UIKeyboardWillHideNotification
UIKeyboardDidHideNotification
于 2013-03-05T08:52:23.213 回答