Diciamo che ho il seguente codice:
IBOutlet UITextField* nameTextField;
IBOutlet UILabel* greetingLabel;
Vorrei greetingLabelleggere "Hello [nameTextField]" non appena l'utente preme un tasto qualsiasi.
Quello di cui ho bisogno fondamentalmente è l'equivalente per iPhone del metodo delegato Cocoa controlTextDidChange.
Il textField:shouldChangeCharactersInRange:metodo delegato viene chiamato ogni volta che si preme un tasto:
- (BOOL) textField:(UITextField *)textField
shouldChangeCharactersInRange:(NSRange)range
replacementString:(NSString *)string
L'argomento stringa restituisce il carattere premuto. Il textFieldvalore effettivo ( nameTextField.text) rimane tuttavia vuoto.
Cosa mi manca qui? (Vorrei nameTextFieldriflettere la stringa esatta che l'utente ha inserito finora).