2

In my app, I have a table view with text labels inside. When a user presses on one of the text labels, the keyboard is shown, but each time the table is reloading, the keyboard disappears. I want to add a check (when the table is reloading) to see if the keyboard is up, and if so , then to make it visible again after reloading is finished. My question is - how can I check if the keyboard is visible? any help will be appreciated. thanks

user2993422
  • 306
  • 2
  • 6
  • 22
  • Have a look at this [link](http://stackoverflow.com/questions/1490573/how-to-programatically-check-whether-a-keyboard-is-present-in-iphone-app). – Vivek Molkar May 13 '15 at 08:38

1 Answers1

8

There are UIKeyboardWillShowNotification and UIKeyboardWillHideNotification notifications of NSNotificationCenter. Just subscribe to them

Azat
  • 6,745
  • 5
  • 31
  • 48
  • Do you know any other way of doing it? I am needing to check whether the keyboard is shown when the devices orientation changes, so that a particular view can reposition itself so that it isn't covered up by the keyboard, since the keyboards for landscape and portrait have different heights. In other words, when my device is rotated a view that needs to be visible is covered by the keyboard. If I had a way to directly check if the keyboard was showing, then I could simply adjust the UI in the device changed orientation function. Alas, I cannot. – ICW Nov 20 '15 at 14:29
  • 1
    @YungGun during interface orientation changes you still will receive that events – Azat Nov 20 '15 at 20:52
  • 3
    @YungGun use a boolean variable to track when is active or not buy by giving it "true" in UIKeyboardWillShowNotification and "false" for UIKeyboardWillHideNotification. this way you can track when its active or not in the said ViewController. – Uche Dim Apr 28 '16 at 16:39