There is no public API to do this. So as was already advised in the comments:you should better implement your own keyboard as UIView
subclass with methods to change its behaviour in the way you need (hide buttons, add new buttons, etc.). There are a lot of tutorials that will teach you how you can do this. Apple also advice to do this here. You should also handle all the localisation support in your own keyboard class if you plan to internationalize your application. So all this stuff will be pretty hard to implement. If you don't want to do this then the only way is to use some dirty views manipulations and access the keyboard as a UIView
object and then do with it whatever you want. BUT it is a very bad way, because it uses private view hierarchy and can be broken when Apple will make some changes in it like it was with UITableViewCell
views hierarchy in iOS 7. And also it is a very limited way. At first you have to be sure that keyboard has already shown to the user or you will have a crash (because windows
array will contain only one UIWindow
). To do this just add a notification observer:
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
[center addObserver:self selector:@selector(keyboardShowed)
name:UIKeyboardDidShowNotification object:nil];
Then in keyboardShowed
method (valid for iOS versions in [4.0,7.1] interval):
-(void)keyboardShowed
{
UIWindow* window = [[[UIApplication sharedApplication] windows]
objectAtIndex:1];
for(UIView* view in window.subviews)
{
if([[view description] hasPrefix:@"<UIPeripheralHostView"])
{
//This view is a keyboard view
// you can iterate its subviews
//and make buttons hidden
NSLog(@"Keyboard Shown: %@", view);
}
}
}
Then when you actually get the reference to keyboard view you should trace it with subviews
property down all the hierarchy (UIKeyboardImpl
,UIKeyboardLayoutStar
and etc.) while you will actually get views like buttons.
But as I said it is a bad way. Because private view hierarchy is huge with a lot of subviews. So you should handle your functionality in some other way. Why just don't allow the user to enter letters which he has already guessed in your game, and show him some sort of alert message?