Reputation: 1876
When using Secure Text Entry
in a UITextField
the text is overwritten if I have entered a text, gone to another text field and coming back and start writing without pressing back.
Now, Im using the following to keep track of the entered text:
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
NSString *text = [textField.text stringByReplacingCharactersInRange:range withString:string];
}
But in the case above, the event doesnt track that the textfield has been cleared thus I cannot always rely on the string text
Any good tips?
Upvotes: 0
Views: 739
Reputation: 368
i can tell you an easy way to do it in the xcode itself.
Select Clear when editing begins
checkbox
Select Secure
checkbox
Upvotes: 0
Reputation: 1876
Okay, I simply changed the logic as track textfield changes with this event instead:
[textField addTarget:self
action:@selector(textFieldDidChange:)
forControlEvents:UIControlEventEditingChanged];
textFieldDidChange
will be called each time the text changes.
Upvotes: 4