Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
653 views
in Technique[技术] by (71.8m points)

ios - Selecting language of the keyboard for UITextField with secureTextEntry

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 to enter login, then it is all right, I can change the keyboard to hebrew and enter login. But when I try to enter password in secured textField, the keyboard appears without select language button, so I can enter only english letters.

The thing is that logins/passwords could be in english or in hebrew.

How can I put the select language button to the secured textField?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Didn't find a solution. Had to make this snippet:

-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
textField.text = [textField.text stringByReplacingCharactersInRange:range withString:string];

NSString *pass = password;
pass = [pass stringByReplacingCharactersInRange:range withString:string];

[password release];
password = nil;

password = [[NSString stringWithString:pass] retain];

[self hideTextInTextFieldExceptOne:string];

[self performSelector:@selector(hideTextInTextField) withObject:self afterDelay:1.0];

return NO;
}

- (void)hideTextInTextFieldExceptOne:(NSString *)string
{    
int lenght = [passwordTextField.text length];

for (int i = 0; i < lenght-1; i++)
{
    NSRange range = NSMakeRange(i, 1);
    passwordTextField.text = [passwordTextField.text stringByReplacingCharactersInRange:range withString:@"*"];
}
}

- (void)hideTextInTextField
{
NSUInteger lenght = [passwordTextField.text length];
passwordTextField.text = @"";

for (int i = 0; i < lenght; i++)
{
    passwordTextField.text = [passwordTextField.text stringByAppendingString:@"*"];
}
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...