How to add Done button to the keyboard?

前端 未结 9 1972
南笙
南笙 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:42

    Set the 'Return Key' option under the text field option in the inspector for your text field. Then right click on the text field and while holding CTRL select 'Did End On Exit' and drag this into your view controllers file. This will create an IBAction method. Give the method a name and then enter the following values:

    [textField becomeFirstResponder];
    [textField resignFirstResponder];
    

    Your method should look like this:

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

提交回复
热议问题