3

I want to know how to make the keyboard appear in an iOS Swift app and remain there permanently. I know it appears when the user touches inside a textfield. That's not what I want. I want it to be there when the user loads up the app and to stay there permanently. I do still want the keyboard to communicate with a textfield as it normally would.

I would also like to be able to use the keyboard in storyboard auto layout and scale/align my buttons around the keyboard, which is asked here:
Xcode storyboard layout size simulation - keyboard up?

What I tried:

If I could simulate a "touch" inside a textfield programmatically I think I can accomplish my task. I would forcibly simulate a "touch" once the app loads and then in the "textFieldShouldReturn" method I can repeat the forced programmatic touch inside the textfield to prevent the keyboard from disappearing. (This may cause the keyboard to disappear and then reappear quickly, which would be ugly and undesirable.) How do I force this fake touch?

In Conclusion:

I am using iOS Storyboard and Swift.

How do I cause a keyboard to load up on start up and remain there even after pressing return/send?

If the above is impossible, how do I programattically force a touch inside a textfield?

pkamb
  • 33,281
  • 23
  • 160
  • 191
user2012741
  • 89
  • 1
  • 8
  • 2
    Sounds like you want to develop a Blackberry app :-) – Nicolas Miari Apr 01 '16 at 01:27
  • maybe you got your own reason to do so, but for me I feel it is very annoying for a keyboard to be appear there all the time. Simply just my opinion. – Lee Apr 01 '16 at 01:28
  • @NicolasMiari I agree with you.You can add custom keyboard view on window.It won't dismiss.But I don't think Apple will permit a 'Blackberry' app. – Lumialxk Apr 01 '16 at 01:37
  • If it's any help, the keyboard typically hides because the text field the user was editing resigns first responder status. Perhaps you can keep the keyboard on screen by implementing the text field delegate methods. – Nicolas Miari Apr 01 '16 at 01:39
  • @NicolasMiari I don't think keyboard will keep for a text field not on screen. – Lumialxk Apr 01 '16 at 01:49
  • Oh, I missed that part. Wonder what's the purpose of a keyboard, then – Nicolas Miari Apr 01 '16 at 01:53
  • Can you explain why do you want the keyboard to stay? Might there are alternate solutions for this. – Amrit Sidhu Apr 01 '16 at 07:52
  • 1
    @AmritSidhu It is a customer request. I was given a layout of how they want their messaging app to look and the layout includes the keyboard on screen. They'd have to redo the art/buttons, or come up with something else to fill the space if I have the keyboard disappear. They've made it clear they don't want to do that. – user2012741 Apr 01 '16 at 16:56
  • That's really sad to hear. Sometimes customers ask the most ridiculous things, and for the most ridiculous reasons. Ask a graphic/web designer if you don't believe me... – Nicolas Miari Apr 05 '16 at 09:55

1 Answers1

1

I think that you can't do this from storyboard side, but from code side, assuming that you name your textfield "textField", you can do self.textField.becomeFirstResponder() on your viewDidLoad() in order to make the keyboard appear when you enter on this screen. This should keep the keyboard on screen unless you do resignFirstResponder() elsewhere.

tx2
  • 724
  • 13
  • 26