Book Image

Application Development in iOS 7

By : Kyle Begeman
Book Image

Application Development in iOS 7

By: Kyle Begeman

Overview of this book

Table of Contents (15 chapters)
Application Development in iOS 7
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Adding the text field delegate


Now that we have our image, we need to set up the text field delegate. This is probably the simplest of all delegate methods because we only need to tell the application what to do when the return key is pressed. For our application, we simply want to hide the keyboard. Below our image picker delegate method, add the following code:

#pragma mark - Text Field Delegate

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

This method simply tells the text view to resign first responder (hide the keyboard) when the return key is pressed. A user can type in a name, press the return key, and hide the keyboard. Make sure that the text fields delegate property has been set to AddNewViewController (self) either in the storyboard or in viewDidLoad.