Подтвердить что ты не робот

UIKeyboardTypeNumberPad - Показать просто онемение на iPad?

UIKeyboardTypeNumberPad не отображает цифровую панель на iPad. Вместо этого он показывает клавиатуру UIKeyboardTypeNumbersAndPunctuation.

Есть ли что-то, что мне не хватает, или это было удалено из iPad OS?

Спасибо за руководство!

4b9b3361

Ответ 1

Я считаю, что это не поддерживается в iPhoneOS 3.2 на iPad

Чтобы указать заголовочный файл UITextInputTraits:

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

Ответ 2

добавить UITextFieldDelegate в ваш файл заголовка (файл .h)

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

затем добавьте этот метод

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

Ответ 3

Я знаю, что этот вопрос давно неактивен, но это может помочь кому-то там.

Вы можете попробовать реализовать эту https://github.com/azu/NumericKeypad. Кодер реализовал свой собственный номерной знак buy subclassing UITextField