简体   繁体   English

如何停止显示字符的UITextField Secure文本

[英]How do I stop UITextField Secure text showing characters

I've enabled Secure text for my UITextField. 我为我的UITextField启用了安全文本。 At runtime when I type some text in I initially see the character before it turns to a bullet point. 在运行时,当我输入一些文本时,我最初会看到该字符变为项目符号。 Is there a way to stop it showing the characters and having it as a bullet point as I type. 有没有办法阻止它显示字符并将其作为我键入的项目符号。

Is there something I need to add to 有什么我需要添加的东西

-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string

Has anyone got an example? 有人有例子吗?

I dont know its good practice or not but following trick did it for me 我不知道它的良好做法,但跟随技巧为我做了

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

That is the default behaviour of the UITextField . 这是UITextField的默认行为。 So there's nothing much you can do about it. 所以你无能为力。 You can play with some kind of encryption on the coding side but on the view side, this behaviour will prevail. 您可以在编码方面使用某种加密,但在视图方面,这种行为将占上风。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM