Вопрос

I want to change keyboard type from default to numeric after user pressed return button. However after setting keyboardType property nothing happens.

My code:

-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField setKeyboardType:UIKeyboardTypeNumbersAndPunctuation];

    return YES;
}

I have set myself as text field delegate and the method is being called after pressing return button.

EDIT: Solved by

-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField setKeyboardType:UIKeyboardTypeNumbersAndPunctuation];
    [textField reloadInputViews];
    return YES;
}
Это было полезно?

Решение

Try this:

-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField setKeyboardType:UIKeyboardTypeNumbersAndPunctuation];
    [textField reloadInputViews];
    return YES;
}

Другие советы

You can do this in the Text Input Traits section under the Attributes inspector.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top