Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIKeyboardTypeNumberPad - Show just numbes on iPad?

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!

like image 266
Daddy Avatar asked Apr 08 '10 04:04

Daddy


People also ask

How do you show numbers on iPad keyboard?

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.

How do you get rid of numbers above letters on iPad keyboard?

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.


2 Answers

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).
//
like image 65
Dustin Howett Avatar answered Sep 18 '22 02:09

Dustin Howett


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;
}
like image 23
Hector Avatar answered Sep 18 '22 02:09

Hector