In several cases I want to add a toolbar to the top of the iPhone keyboard (as in iPhone Safari when you're navigating form elements, for example).
Currently I am specifying the toolbar's rectangle with constants but because other elements of the interface are in flux - toolbars and nav bars at the top of the screen - every time we make a minor interface change, the toolbar goes out of alignment.
Is there a way to programmatically determine the position of the keyboard in relation to the current view?
As of iOS 3.2 there's a new way to achieve this effect:
UITextFields
and UITextViews
have an inputAccessoryView
property, which you can set to any view, that is automatically displayed above and animated with the keyboard.
Note that the view you use should neither be in the view hierarchy elsewhere, nor should you add it to some superview, this is done for you.