¿Cómo mostrar mi botón cuando se presionó el botón BORRAR DE TEXTFIELD?
Pregunta
Revise mi campo de texto así:
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
if ([subtitleField.text length] == 0)
{
searchAddress.hidden = NO;
}
else
{
searchAddress.hidden = YES;
}
return YES;
}
Pero funciona solo si borra el campo de texto por llave clara, si presiono el botón Borrar, no funcionó.
Solución
Implementar el método [UITextFieldDelegate textFieldShouldClear:]
también:
- (BOOL)textFieldShouldClear:(UITextField *)textField
{
searchAddress.hidden = NO;
return YES;
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow