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

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

http://blog.sina.com.cn/s/blog_70ba46340100oteq.html
 

 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];
}

 
posted @ 2012-09-10 17:03  zander  阅读(420)  评论(0编辑  收藏  举报