This is my code:
- (BOOL) textFieldShouldReturn:(UITextField *)textField {
[txtSiteDesc resignFirstResponder];
[txtDesc resignFirstResponder];
[ssFS resignFirstResponder];
return YES;
}
This is the .h file:
#import <UIKit/UIKit.h>
@interface slEnterDataViewController : UITableViewController <UITextFieldDelegate> {
UITextField *txtSiteDesc;
UITextField *txtDesc;
UITextField *ssFS;
}
@property (nonatomic, retain) IBOutlet UITextField *txtSiteDesc;
@property (nonatomic, retain) IBOutlet UITextField *txtDesc;
@property (nonatomic, retain) IBOutlet UITextField *ssFS;
@end
It works for the txtSiteDesc, but not any of the others. I assume the problem is in the textFieldShouldReturn method; I thought I could check the value of “textField” to see which field it is and then execute the appropriate “resignFirstResponder” and return. I’m close (I think) but not close enough.
Help would be greatly appreciated. 😀
Is it possible that you’ve set the delegate for
txtSiteDescbut not for your other two text fields? This would explain whytextFieldShouldReturn:is called for your first text field not not the others. Make sure you are setting thedelegateproperty of all three textfields toself(where self = your view controller).