You can do this using UIKeyboardWillShowNotification
look into UIWindow reference for information about it :
[[NSNotificationCenter defaultCenter]
addObserver:self selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification object:nil];
This notification is raised when a textfield even from a UIWebView
is selected.
Look at Apple KeyboardAccessory Sample code which shows how to do this. That sample code use the UITextXxxx inputAccessoryView
property, that I doubt you will be able to use. But the notification will give you enough information to add your accessory directly in your view or even on top UIWindow, and that even by animating it with the keyboard :
(gdb) po notification
NSConcreteNotification 0xb5a2190 {name = UIKeyboardWillShowNotification; userInfo = {
UIKeyboardAnimationCurveUserInfoKey = 0;
UIKeyboardAnimationDurationUserInfoKey = "0.300000011920929";
UIKeyboardBoundsUserInfoKey = "NSRect: {{0, 0}, {320, 260}}";
UIKeyboardCenterBeginUserInfoKey = "NSPoint: {160, 610}";
UIKeyboardCenterEndUserInfoKey = "NSPoint: {160, 350}";
UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0, 480}, {320, 260}}";
UIKeyboardFrameEndUserInfoKey = "NSRect: {{0, 220}, {320, 260}}";
}}