Comment montrer mon bouton lorsque le bouton Effacer Textfield a été enfoncé?
Question
Je vérifie mon champ de texte comme ceci:
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
if ([subtitleField.text length] == 0)
{
searchAddress.hidden = NO;
}
else
{
searchAddress.hidden = YES;
}
return YES;
}
Mais cela ne fonctionne que si je ne transmise pas de textfield par clé claire, si j'appuie sur le bouton Effacer, il n'a pas fonctionné.
La solution
Implémentez aussi la méthode [UITextFieldDelegate textFieldShouldClear:]
:
- (BOOL)textFieldShouldClear:(UITextField *)textField
{
searchAddress.hidden = NO;
return YES;
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow