如何知道何时将文本粘贴到 UITextView 中 [英] how to know when text is pasted into UITextView

查看:34
本文介绍了如何知道何时将文本粘贴到 UITextView 中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将文本块粘贴到 UITextView 时会触发什么事件?粘贴文本时需要修改textView的frame.

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.

感谢阅读.

推荐答案

你的 UITextView 将调用它的 UITextViewDelegate 方法

Your UITextView will call its UITextViewDelegate method

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

如果已设置委托.当在键盘上输入字符时,以及将文本粘贴到文本视图中时,都会调用此方法.粘贴的文本是replacementText 参数.

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.

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

这篇关于如何知道何时将文本粘贴到 UITextView 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆