Reputation: 95
Is it possible to switch between number input view and letters input view of UIKeyboardTypeASCIICapable with code? I want to show the number input view by default but allow user to input character as well. I need
Upvotes: 0
Views: 475
Reputation: 318774
There's no direct way to simulate the pressing of the 123
key on the iPhone keyboard to switch between the numbers/symbols and the letters of the keyboard.
What you can do is switch between two different keyboard types though. Example:
someTextField.keyboardType = UIKeyboardTypeASCIICapable; // start with one type
Then when you want to switch you can do:
- (void)toggleKeyboardType:(UITextField *)textfield {
if (textfield.keyboardType == UIKeyboardTypeNumbersAndPunctuation) {
textfield.keyboardType = UIKeyboardTypeASCIICapable;
} else {
textfield.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
}
[textfield reloadInputViews];
}
Upvotes: 1