UIKeyboardTypeNumberPad doesn't display a number pad on the iPad. Instead, it shows the UIKeyboardTypeNumbersAndPunctuation keyboard.
Is there something I'm missing, or has this been removed from the iPad OS?
Thanks for your guidance!
If a keyboard isn't already visible, tap the Show Keyboard button , then tap the Formula Keyboard button to begin editing a formula. To quickly enter a number or symbol on an iPad, drag down on a key and then lift your finger, or switch to the numeric keyboard on iPhone.
All of the keys that have a grey letter or number character above them will do that. You can turn off Key Flicks in Settings to remove those additional characters. Go to Settings>General>Keyboards>Enable Key Flicks and turn that Off. That solved the problem as you can tell from the no numbers written response.
I believe that this is not currently supported in iPhoneOS 3.2 on the iPad
To quote the UITextInputTraits header file:
//
// UIKeyboardType
//
// Requests that a particular keyboard type be displayed when a text widget
// becomes first responder.
// Note: Some keyboard/input methods types may not support every variant.
// In such cases, the input method will make a best effort to find a close
// match to the requested type (e.g. displaying UIKeyboardTypeNumbersAndPunctuation
// type if UIKeyboardTypeNumberPad is not supported).
//
add UITextFieldDelegate
in your header file (.h file)
txtfield_name.keyboardType=UIKeyboardTypeNumbersAndPunctuation;
txtfield_name.delegate=self;
then add this method
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
NSString *validRegEx =@"^[0-9]*$"; //change this regular expression as your requirement
NSPredicate *regExPredicate =[NSPredicate predicateWithFormat:@"SELF MATCHES %@", validRegEx];
BOOL myStringMatchesRegEx = [regExPredicate evaluateWithObject:string];
if (myStringMatchesRegEx)
return YES;
else
return NO;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With