How to add Done button to the keyboard?

前端 未结 9 1891
南笙
南笙 2020-12-23 17:23

UPDATE:

I also tried implementing UITextViewDelegate delegate and then doing in my controller:

- (BOOL)textViewShouldEndEditing:(UITextView *)textVie         


        
9条回答
  •  生来不讨喜
    2020-12-23 17:50

    Go into your storyboard, select your text field and under the Attributes Inspector there is an option that says "return key"...select "Done".

    Then go into your ViewController and add:

    - (IBAction)dismissKeyboard:(id)sender;
    {
        [textField becomeFirstResponder];
        [textField resignFirstResponder];
    }
    

    Then go back to your text field, click outlets and link "Did end on exit" to dismissKeyboard action.

提交回复
热议问题