4

I'm searching a way to add a button into the accessory view of a keyboard, the one that comes up when touching an input field into a UIWebView, without using some private functions or some questionable tricks.

enter image description here

Do you know how I may do this ?

Note : I know how I may catch the keyboard show/hide events. What I'm asking for is how to add the button.

Oliver
  • 23,072
  • 33
  • 138
  • 230
  • Hi have a look into the following link http://gabriel-tips.blogspot.com/2011/05/input-accessory-view-how-to-add-extra.html – karthick Nov 13 '11 at 15:06

3 Answers3

1

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}}";
}}
Vincent Guerci
  • 14,379
  • 4
  • 50
  • 56
0

UIKit allows applications to substitute custom input views for the system keyboard. It also enables applications to have an accessory view above the system keyboard or custom input view. Additionally, it enables applications to play key-click sounds when users tap on a controls of an input view or input accessory view.

Refer here for more

Oliver
  • 23,072
  • 33
  • 138
  • 230
gigahari
  • 671
  • 1
  • 7
  • 19
0

Take a look at this apple example, as it does exactly what you are searching for. But in general the idea is to replace the inputAccessoryView for the UIWebView in order to show your custom view.

PakitoV
  • 2,476
  • 25
  • 34