Once the code bellow is executed, the textfield’s text doesn’t change in the UI to “Fly” but the second NSLog does print “TextField: Fly” as it should.
@property (strong, nonatomic) IBOutlet UITextField *typeTextField;
....
UITableViewCell* cell = [self.theTableView dequeueReusableCellWithIdentifier:@"TypeCell"];
self.typeTextField = (UITextField*)[cell viewWithTag:1];
NSLog(@"TextField: %@ ", self.typeTextField.text);
self.typeTextField.text = @"Fly";
NSLog(@"TextField: %@ ", self.typeTextField.text);
Any help would be much appreciated.
You almost definitely forgot to connect the outlet for the UITextField in interface builder. Bring up the .xib file that that
typeTextFieldis visible in, click on typeTextField, then show the Utility pane (the one on the far right in Xcode 4+). Click the Connections Inspector (the one that looks like a right arrow) and drag a New Referencing Outlet to your File’s Owner.When you don’t connect the UITextField you drew in Interface Builder with the IBOutlet that you identified in your source file, both UITextFields get created as separate entities. You can make changes and work with the valid typeTextField with a broken IBOutlet, but it’ll never appear on your view.
Consult How to connect an IBOutlet from an UITableViewController directly to custom cell? and http://www.youtube.com/watch?v=d_kO-J3DYvc on properly wiring your custom UITableViewCell objects.