How to add Done button to the keyboard?

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

    In Interface Builder on the properties of the textView you can set the return button type to Done.

    Then you need to check for when the Return button is pressed using

      - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
    

    Check if the text == "/n" then dismiss the keyboard by resigning first responder on your textView.

提交回复
热议问题