【问题标题】:How to know the UIkeyboard is appeared or not in iOS? [duplicate]如何知道 UIkeyboard 是否出现在 iOS 中? [复制]
【发布时间】:2013-02-19 14:00:15
【问题描述】:

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

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

请提出任何解决方案。

提前致谢。

【问题讨论】:

标签: iphone ios objective-c cocoa-touch uikeyboard


【解决方案1】:

测试一下:

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

【讨论】:

    【解决方案2】:

    From official Documentation.

    使用键盘通知检查UIKeyBoard 的状态。

    键盘通知:

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

    UIKeyboardWillShowNotification
    UIKeyboardDidShowNotification
    UIKeyboardWillHideNotification
    UIKeyboardDidHideNotification
    

    【讨论】:

      猜你喜欢
      • 2023-01-18
      • 2012-11-20
      • 1970-01-01
      • 1970-01-01
      • 2011-08-23
      • 2016-01-09
      • 1970-01-01
      • 2014-05-08
      • 1970-01-01
      相关资源
      最近更新 更多