Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


hide keyboard in IOS simulator

Hi I'm trying to get the keyboard to return when the user is done typing. When I add the Text field should return in Xcode 5 I get an error message of undeclared use of Text field should return.

here is my code:

import "LoginViewController.h"

import "RegisterViewController.h"

@interface LoginViewController () @property (nonatomic, strong) IBOutlet UITextField *userTextField; @property (nonatomic, strong) IBOutlet UITextField *passwordTextField; @end

@implementation LoginViewController

  • (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) {

    } return self; }

pragma mark - Private methods

-(IBAction)logInPressed:(id)sender { [PFUser logInWithUsernameInBackground:self.userTextField.text password:self.passwordTextField.text block:^(PFUser *user, NSError *error) { if (user) { [self performSegueWithIdentifier:@"LoginSuccesful" sender:self]; } else { [[[UIAlertView alloc] initWithTitle:@"Error" message:[error userInfo][@"error"] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show]; }




1 Answer

Stone Preston
Stone Preston
42,016 Points

you need to conform to the UITextField delegate protocol by adding <UITextFieldDelegate> to your interface declaration

@interface LoginViewController () <UITextFieldDelegate>

and then set your text fields delegate in viewDidLoad

self.myTextField.delegate = self;

then you should be able to implement that delegate method without error