how to know when text is pasted into UITextView

后端 未结 9 483
暗喜
暗喜 2020-11-30 10:15

What event is fired when a block of text is pasted into a UITextView? I need to modify the frame of my textView when the text is pasted in.

Thanks for reading.

9条回答
  •  野性不改
    2020-11-30 10:21

    Your UITextView will call its UITextViewDelegate method

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

    if a delegate has been set up. This gets called both when a character is typed on the keyboard, and when text is pasted into the text view. The text pasted in is the replacementText argument.

    See http://developer.apple.com/library/ios/#documentation/uikit/reference/UITextViewDelegate_Protocol/Reference/UITextViewDelegate.html#//apple_ref/occ/intf/UITextViewDelegate

提交回复
热议问题