1

Possible Duplicate:
How to programatically check whether a keyboard is present in iphone app?
Detect if UIKeyBoard is Showing

Is there a way to programmatically check if the iPhone's keyboard is on screen or not?

Community
  • 1
  • 1
Mason
  • 6,893
  • 15
  • 71
  • 115

1 Answers1

8

Basically, you want to add an NSNotificationCenter observer:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow) name:UIKeyboardDidShowNotification object:nil];
WrightsCS
  • 50,551
  • 22
  • 134
  • 186
  • 2
    I don't want it to necessarily call a function upon receiving the notification, though, I just want it to check before it adds a subview. It'll affect the frame of the subview. – Mason Oct 21 '11 at 22:15
  • Oh wait, never mind. I can just change the value of a boolean. Thanks! – Mason Oct 21 '11 at 22:17
  • You can set the `selector` to **`nil`**, but how else do you expect to know when it appears? – WrightsCS Oct 21 '11 at 22:17