So I know you have to put this in the .h file:
- (void)textDidEndEditing:(NSNotification *)aNotification
BUT what开发者_JAVA百科 do I call in the .m file?? How do I show that text is done editing in one of several NSTextFields?
I looked around on the internet, but it seems pretty vague on how to use it correctly.
Any ideas? Elijah
Take a look at UITextFieldDelegate
. It will give you the method callbacks you want, such as textfieldDidEndEditing
. It should pass the text field which you can then identify by object comparison or tag value.
UPDATE
Code sample for the delegate callback. Be sure to add UITextFieldDelegate
to your .h file. Also specific your textField's delegate property, textField.delegate = self
in your code or in IB.
- (void)textFieldDidEndEditing:(UITextField *)textField {
if (textField.returnKeyType == UIReturnKeyDone) {
// the textfield with the Done return key is what I care about
self.value2 = [textField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
}
}
精彩评论