views:

307

answers:

1

Hi,

In a certain view I have got different elements and I need the keyboard to stay always on the screen.

In iPhone OS 3.0, when touching text the keyboard gets dismissed sometimes. How can I keep it from dismissing?

What is the best way to do so?

Thanks.

+2  A: 

Ordinarily, the keyboard stays up until you explicitly dismiss it through resignFirstResponder. But if you're using Interface Builder, there is a checkmark 'auto-enable return key' on text fields that is set by default which does the auto-dismiss thing.

If you're using IB uncheck that flag and then you're in charge of dismissing the keyboard yourself by calling resignFirstResponder when you're done with editing.

Ramin
Nope, I am adding it programatically. The problem occurs only in iPhone os 3.0 because of newly introduced "copy/paste" feature. My text view is not editable and the keyboard is supposed to always stay on screen. But when user touches the text view, the keyboard dismisses in order to allow select text, which I don't want.What's the right solution in this situation?
Ilya
Ah, you should have mentioned copy/paste issues in your original question. You can try subclassing the TextView, over-riding canResignFirstResponder, and returning NO. Can't guarantee it won't mess with copy-paste operations, though.
Ramin
This answer is factually incorrect - the "Auto-enable Return Key" in IB makes it so the return key is disabled until text is entered into the text field. It has nothing to do with auto-dismissing the keyboard.
Josh Brown