Clicking in a textfield makes the keyboard appear. How do I hide it when the user presses the return key?
First make your file delegate for UITextField
@interface MYLoginViewController () <UITextFieldDelegate>
@end
Then add this method to your code.
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder];
return YES;
}
Also add self.textField.delegate = self;