I'm using the code below to try and have textField2
's text content get updated to match textField1
's whenever the user types in textField1
.
- (BOOL) textField: (UITextField *)theTextField shouldChangeCharactersInRange: (NSRange)range replacementString: (NSString *)string {
if (theTextField == textField1){
[textField2 setText:[textField1 text]];
}
}
However, the output I observe is that...
textField2 is "12", when textField1 is "123"
textField2 is "123", when textField1 is "1234"
... when what I want is:
textField2 is "123", when textField1 is "123"
textField2 is "1234", when textField1 is "1234"
What am I doing wrong?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…