Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITextField functionality with no keyboard

Tags:

I am building an application with a custom interface for entering text, and was using a UILabel for display. It then became necessary for the user to be able to copy and paste the text, so I went with a UITextField.

The problem I have is that I can't figure out how to get the UITextField to allow selection, copy, paste, etc, but have no keyboard displayed when the field is selected.

I have read numerous posts similar to this but none ask exactly the same thing, nor do any of the solutions work for me. I've tried making the field non-editable, which does block the keyboard from coming up, but also doesn't allow copying and pasting. I've also read comments suggesting subclassing the UITextField, but none I've read have given concrete examples.

Can what I want be done simply, or do I need to go the route of creating a custom view for the keyboard, or other options?

Thanks, Andrew

Solution:

In the end, I discovered another similar (but not exact) question here on stackoverflow, and one answer gave a solution to my problem. The way to go about it is simply to have the app display a dummy View as the keyboard, and everything else works the way it should.

UIView *dummyView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1, 1)];     VIN.inputView = dummyView; // Hide keyboard, but show blinking cursor 

It works for UITextField and UITextView and they need to be set to editable.

like image 467
Andrew Hoyer Avatar asked Jan 09 '12 00:01

Andrew Hoyer


1 Answers

Solution:

In the end, I discovered another similar (but not exact) question here on stackoverflow, and one answer gave a solution to my problem. The way to go about it is simply to have the app display a dummy View as the keyboard, and everything else works the way it should.

UIView *dummyView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1, 1)];     VIN.inputView = dummyView; // Hide keyboard, but show blinking cursor 

It works for UITextField and UITextView and they need to be set to editable.

like image 92
Andrew Hoyer Avatar answered Oct 02 '22 01:10

Andrew Hoyer