i’m trying to clear a UITextField whenever the UIControlEventEditingChanged event is being performed.
However, when I set the text to nothing, the UIControlEventEditingChanged event is being called again, and this is the way it keeps going.
This is my code:
- (void)updateText {
//other code
textfield.text = @"";
//other code
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[textfield addTarget:self action:@selector(updateText) forControlEvents:UIControlEventEditingChanged];
}
I would like to be able to set the text of the text field without it looping infinitely!
Any help appreciated.
Not sure this is the best way, but before you do your programmatic update to the textfield you could remove your UIControlEventEditingChanged listener and then add it again afterwards.