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;
}
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