判断 iPhone 虚拟键盘是否打开的代码
http://blog.sina.com.cn/s/blog_70ba46340100oteq.htmlCocoaChina 会员“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];
}