I have a UITextView
that I would like to allow users to Paste into but not type into (not copy from or paste from) but not show the keyboard. I have tried the editable / selectable behaviors but they don't work.
I have also tried resignFirstRepsonder
in the textViewShouldBeginEditing
method.
So can anyone help me.
The easiest solution would probably be to have a customized "paste" function entirely. For example, have a UITextField that isn't selectable/editable at all, and then a "Paste" button hooked up to a method like this:
- (IBAction)paste {
UIPasteboard *pb = [UIPasteboard generalPasteboard];
textField.text = [pb string];
}
That way when they press the button, whatever text they've copied will appear in the TextField, but you won't have to worry about the keyboard behaviors because the user never actually interacts with it.
You could even do that code above when the user selects the TextField itself, and then simply stop the keyboard from appearing, but that would be counter-intuitive from a UI standpoint. Better to have a button that they tap, rather than altering the well-established behavior of selecting a TextField.