Domanda

Controllo il mio TextField come questo:

-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
    if ([subtitleField.text length] == 0)
    {
        searchAddress.hidden = NO;
    }
    else 
    {
        searchAddress.hidden = YES;
    }

   return  YES;   
}
.

Ma funziona solo se ho cancellato TextField per chiave clear, se premo il pulsante Cancella, non funzionava.

È stato utile?

Soluzione

Attuare anche il metodo [UITextFieldDelegate textFieldShouldClear:]:

- (BOOL)textFieldShouldClear:(UITextField *)textField
{
    searchAddress.hidden = NO;
    return YES;
}
.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top