views:

56

answers:

3

I'm following this iPhone tutorial from Apple and I think I did everything correctly, however the app is not behaving as it should. I checked the troubleshooting section and I still think I got things right.

So I guess I need help to tell where the problem is... here is a snapshot of the relevant connections in Interface Builder.

Basically, the keyboard's Done button doesn't dismiss the keyboard, and the Hello button from the view doesn't trigger the changeGreeting method.

If you can't tell what's missing, just ask for me to post some code or whatever is relevant. Thanks!

IB connections

This is in the controller:

- (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
    if (theTextField == textField) {
        [textField resignFirstResponder];
    }

    return YES;
}

Edit: I'm an idiot, I hadn't saved the nib file, thought I had. Sorry!

+1  A: 

Have you implemented the "ResignFirstResponder" message in the textFieldShouldReturn: method? That is what tells the keyboard to disappear when the text field is done being edited. This is explained in the "Implementing the View Controller" section of the tutorial.

Silverlock
Yes, please see the edit
Germán
+1  A: 

The interface builder outlets look alright. In the code of your application view controller, do you have something like:

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    [textField resignFirstResponder]; 
    return YES; 
}

In order to dismiss the text field, you need to implement the UITextFieldDelegate. Seems like an annoying default to me, but must be done!

Kevin Sylvestre
Yes, please see the edit
Germán
A: 

All right, besides the fact that I was an idiot for not having saved the nib file... once I did, my view wasn't loading anymore, raising an exception.

Turns out this connection was missing:

Files Owner connections

The funny thing is I don't remember having made it before when the view was being loaded. I tried this and everything works now.

Germán