views:

400

answers:

2

I have an iPhone app with a UITextView. I'd like to be able to paste the clipboard contents into it without showing the UIMenuController.

I tried calling the paste: method on the UITextView, and on the first responder, but neither of those things worked.

I was able to implement this by writing a bunch of code to read text from the clipboard, insert it in the UITextView's text property, and update the selection range. I also added support for undo/redo. But it seems like there ought to be an easier way. Is there?

A: 

Did you try making the UITextView the first responder?

JoBu1324
Yes, did that, and keyboard was visible.
Kristopher Johnson
A: 

I checked out the headers to the UITextView object, but I couldn't find any documented method called -paste; also, looking over the NSPasteboard class suggests to me that programatically setting your text was the right way to go.

If pasting text is important to your app, I would consider setting up a class to handle it; maybe even make it a singleton if it was important enough.

Good luck!

JoBu1324