How to make return key on iPhone make keyboard disappear?
问题 I have two UITextFields (e.g. username and password) but I cannot get rid of the keyboard when pressing the return key on the keyboard. How can I do this? 回答1: First you need to conform to the UITextFieldDelegate Protocol in your View/ViewController's header file like this: @interface YourViewController : UIViewController <UITextFieldDelegate> Then in your .m file you need to implement the following UITextFieldDelegate protocol method: - (BOOL)textFieldShouldReturn:(UITextField *)textField {