按下TextField清除按钮时如何显示我的按钮?
题
我像这样检查我的文字场:
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
if ([subtitleField.text length] == 0)
{
searchAddress.hidden = NO;
}
else
{
searchAddress.hidden = YES;
}
return YES;
}
.
但只有在通过清除键清除文本字段时才有效,如果我按清除按钮,它就不起作用。
解决方案
也实现了[UITextFieldDelegate textFieldShouldClear:]
方法:
- (BOOL)textFieldShouldClear:(UITextField *)textField
{
searchAddress.hidden = NO;
return YES;
}
. 不隶属于 StackOverflow