2010-04-08 15 views
17

UIKeyboardTypeNumberPad non visualizza un tastierino numerico sull'iPad. Invece, mostra la tastiera UIKeyboardTypeNumbersAndPunctuation.UIKeyboardTypeNumberPad - Mostra solo numbes su iPad?

C'è qualcosa che mi manca o che è stato rimosso dal sistema operativo iPad?

Grazie per la vostra guida!

+1

Non è che è stato rimosso, ma piuttosto che non è mai stato lì in primo luogo. Devi creare la tua tastiera per farlo. Vedi: [Come posso recuperare i tasti da una tastiera personalizzata su un'app per iOS?] (Http://stackoverflow.com/a/13351686/937822) – lnafziger

risposta

13

credo che questo non è attualmente supportato in iPhoneOS 3.2 sull'iPad

per citare l'UITextInputTraits file di intestazione:

// 
// 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). 
// 
+1

Ma l'ho visto sull'iPad all'interno di un popover. Come hanno fatto? – David

+3

Probabilmente l'hanno appena implementato. – ceejayoz

2

So che questa domanda è stato inattivo per un po 'di tempo, ma questo potrebbe aiutare qualcuno là fuori.

È possibile provare a implementare questo https://github.com/azu/NumericKeypad. Il codificatore implementato il proprio tastierino numerico acquistare sottoclasse della UITextField

+0

Grazie, è bello – Justin

8

aggiungere UITextFieldDelegate nel file di intestazione (file h)

txtfield_name.keyboardType=UIKeyboardTypeNumbersAndPunctuation; 
txtfield_name.delegate=self; 

quindi aggiungere questo metodo

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{ 

NSString *validRegEx [email protected]"^[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; 
} 
+1

Questo non fa quello che chiede la domanda (per mostrare solo i numeri su un iPad), ma utilizza la tastiera predefinita (con lettere, ecc.) E limita l'input in modo che siano consentiti solo numeri. – lnafziger

Problemi correlati