如何在iOS中将文本粘贴到UITextView中?

时间:2012-07-04 11:10:12

标签: ios

我有一个UITextView,我想用按钮的点击事件将文本粘贴到UITextView中。

你知道,当我点击一个按钮时,从任何地方复制的文本都会粘贴到该UITextView中。

我该怎么做?

提前致谢。

3 个答案:

答案 0 :(得分:2)

-(IBAction)buttonPressed:(id)sender
{
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
MsgtextView.text = [NSString stringWithFormat:@"%@ %@",MsgtextView.text,pasteboard.string;
}

检查

答案 1 :(得分:2)

您可以使用UIPasteboard课程。

答案 2 :(得分:2)

试试此代码



    UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
    textView.text = pasteboard.string;