Selecting language of the keyboard for UITextField with secureTextEntry

后端 未结 3 1617
灰色年华
灰色年华 2020-12-19 04:48

I\'m stuck with a problem of changing language for the password field. In my application I need to enter login/password in hebrew with no care of current locale. When I try

3条回答
  •  佛祖请我去吃肉
    2020-12-19 05:17

    Optimized @lonlywolf answer to better performance code: Optimized only two methods where are cycles, which slowed down program when typing more than 30 symbols

    - (void)hideTextInTextFieldExceptOne:(NSString *)string
    {
        int lenght = [passwordTextField.text length];
        if (lenght -1 > 0) {
            NSString *resultString = @"";
            for (int i = 0; i < lenght-1; i++)
            {
                resultString = [resultString stringByAppendingFormat:@"*"];
            }
            NSRange range = NSMakeRange(0, lenght - 1);
            passwordTextField.text = [fieldPassword.text stringByReplacingCharactersInRange:range withString:resultString];
        }
    }
    
    - (void)hideTextInTextField
    {
        int lenght = [passwordTextField.text length];
        if (lenght > 0) {
            NSString *resultString = @"";
            for (int i = 0; i < lenght; i++)
            {
                resultString = [resultString stringByAppendingFormat:@"*"];
            }
            passwordTextField.text = resultString;
        }
    }
    

提交回复
热议问题