您的位置:首页 > 编程语言

判断 iPhone 虚拟键盘是否打开的代码

2013-01-10 13:48 211 查看
CocoaChina 会员“qqn_pipi”分享的判断 iPhone 虚拟键盘是否打开的代码,原理很简单:看当前的窗口是否存在一个 responder,从而判别 iPhone 的键盘是否打开了。

BOOL TTIsKeyboardVisible() {

// Operates on the assumption that the keyboard is visible if and only if there is a first

// responder; i.e. a control responding to key events

UIWindow* window = [UIApplication sharedApplication].keyWindow;

return !![window findFirstResponder];

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: