如何以编程方式检查 iOS 应用程序中是否存在键盘? [英] How can I programmatically check whether a keyboard is present in iOS app?

查看:27
本文介绍了如何以编程方式检查 iOS 应用程序中是否存在键盘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在我的 iOS 应用中检查键盘可见性的情况.

I need to check the condition of keyboard visibility in my iOS app.

伪代码:

if(keyboardIsPresentOnWindow) {
    //Do action 1
}
else if (keyboardIsNotPresentOnWindow) {
    //Do action 2
}

我如何检查这种情况?

推荐答案

...或采取简单的方法:

…or take the easy way:

当您输入 textField 时,它会成为第一响应者并出现键盘.您可以使用 [myTextField isFirstResponder] 检查键盘的状态.如果返回YES,则键盘处于活动状态.

When you enter a textField, it becomes first responder and the keyboard appears. You can check the status of the keyboard with [myTextField isFirstResponder]. If it returns YES, then the the keyboard is active.

这篇关于如何以编程方式检查 iOS 应用程序中是否存在键盘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆