views:

180

answers:

2

Is there any way to copy text from a TextView that has User Interaction is enabled to the clipboard via a UIButton?

But instead of the user holding down his finger on the uitextview so that the apple standard window popups to copy I want the user to be able to do with just the click of the button .. (Whole text)

Regards,

+3  A: 

In the button's target action, call

[UIPasteboard generalPasteboard].string = whateverStringYouWantToCopy;
KennyTM
@kenny I want to copy all the text the user can type in the uitextview .. > whateverStringYouWantToCopy > sorry did not get that.. noob here :(
@user: So change `whateverStringYouWantToCopy` to `theTextView.text`.
KennyTM
A: 

You could take the actual UIView, that the current UIViewController shows and loop through the subviews to get all UITextView's that have user interaction enabled. Or do you have only one textview?

You can get the text of a UITextView with its text property and copy this text with the method KennyTM described above:

[UIPasteboard generalPasteboard].string = yourTextView.text;
schaechtele