我像这样查看我的文本域:
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
if ([subtitleField.text length] == 0)
{
searchAddress.hidden = NO;
}
else
{
searchAddress.hidden = YES;
}
return YES;
}
但只有当我通过清除键清除文本字段时它才有效,如果我按下清除按钮,它就不起作用。
答案 0 :(得分:4)
同样实施[UITextFieldDelegate textFieldShouldClear:]
方法:
- (BOOL)textFieldShouldClear:(UITextField *)textField
{
searchAddress.hidden = NO;
return YES;
}