is there an event when keyboard comes out or retracts

Discussion in 'iOS Programming' started by beachdog, Oct 17, 2008.

  1. beachdog macrumors member

    Aug 10, 2008
    I am finding that when the keyboard comes out and overlays part of my view, that I need to respond by changing the contentSize of the underlying view in order that the user can properly scroll the items now hidden under the keyboard if need be. Otherwise, there is no way for the user to scroll the underlying controls into view, other than doing something to leave the text field and thereby cause the keyboard to retract. It's nicer, however, if the user still has full scrolling possibilities when the keyboard is extended.

    As best I can tell, the keyboard overlays the view beneath, and no action is taken by the UI framework to adjust the scrolling. So I have to do it myself, by resetting the contentSize -- increasing the height of the contentSize so it can be scrolled up further such that the entire view can be brought into view. That is all fine, and I have it working well, but I also need to resize the view(s) back down to normal when the keyboard retracts. So I am wondering, are there any specific events generated when the keyboard extends and/or retracts? I would like notification of that so I can centralize my code that has to fiddle with views.

    BTW, if there is some much easier way of dealing with the keyboard/view interaction please let me know. It's something I had expected would be taken care of automatically by the framework and was surprised to not find a simpler solution, so if I've missed it let me know.
  2. PhoneyDeveloper macrumors 68040


    Sep 2, 2008
    There are some notifications listed at the bottom of UIWindow.h related to the keyboard. If you're using UITextField there are some delegate callbacks that you can implement that also get called when the keyboard is starting or ending.

Share This Page