Custom Keyboard: inputView: how to change the Keyboard size?

Paoloandrea picture Paoloandrea · May 18, 2011 · Viewed 14.3k times · Source

I implemented the textfield with a custom keyboard with the "setInputView" function. But i have a problem: my keyboard frame is not a standard iphone keybord frame.

The question is: How can i change the size of my custom keyboard? I know some functions like: UIKeyboardFrameBeginUserInfoKey, ..etc.

Please Note: The iPhone keyboard frame is = 0,264,320,216 My custom keyboard frame is = 0,0,320,460

Hoping for your kind collaboration, Best regards... P

Answer

msgambel picture msgambel · Oct 26, 2011

It turns out that the default behaviour of the custom input view that you assign to the UITextField's property is to resize the view to the same frame as the default keyboard. Try setting (I use the name InputViewController for my input view, but you can use whatever you want):

inputViewController = [[InputViewController alloc] initWithNibName:@"InputViewController" bundle:nil];
inputViewController.delegate = self;
inputViewController.view.autoresizingMask = UIViewAutoresizingNone; // This is the code that will make sure the view does not get resized to the keyboards frame.

For more detailed information, you can look at this link, which is provided by Apple.:

If UIKit encounters an input view with an UIViewAutoresizingFlexibleHeight value in its autoresizing mask, it changes the height to match the keyboard.

Hope that Helps!