How to show my button when textfield clear button was pressed?
Question
I check my textfield like this:
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
if ([subtitleField.text length] == 0)
{
searchAddress.hidden = NO;
}
else
{
searchAddress.hidden = YES;
}
return YES;
}
but it works only if I clear textfield by clear key, if I press clear button, it didn't work.
Solution
Implement the [UITextFieldDelegate textFieldShouldClear:]
method as well:
- (BOOL)textFieldShouldClear:(UITextField *)textField
{
searchAddress.hidden = NO;
return YES;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow