Reputation: 88
Is it possible to access/remove buttons from the keyboard on iPad?
I want the user to have access only to the number keyboard without possibility to switch between other types of keyboard. For this, i need to hide/disable "switch buttons" (buttons with label "ABC").
To access the keyboard i use:
UIWindow * tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];
UIView* keyboard;
for(int i = 0; i < [tempWindow.subviews count]; i++)
{
keyboard = [tempWindow.subviews objectAtIndex:i];
if([[keyboard description] hasPrefix:@"<UIKeyboard"] == YES)
{
// access elements of keyboard
}
}
Also, the problem is that [keyboard.subviews count] = 0
, while the keyboard was found.
Upvotes: 0
Views: 939
Reputation: 49354
Each UITextField
conforms to text input protocol called UITextInputTraits
which declares property keyboardType
. You can define the keyboard in interface builder or calling setKeyboardType:
method on your text field. The keyboard types are defined in documentation. In your particular case you should use UIKeyboardTypeDecimalPad
for number input.
Upvotes: 1