How to show a keyboard via press a NSButton?

Webber Lai picture Webber Lai · Dec 8, 2010 · Viewed 17.7k times · Source

I only know few ways to show a keyboard on iOS

touch textfield,search bar,textview.....

Is it can via touch a button to show keyboard ???

I wish I can use this way to set a button tittle if the button is no tittle or can rename it.

Thank you guys~

Answer

Constantin picture Constantin · Dec 8, 2010

You need to add an UITextField to your view and call then [myTextfield becomeFirstResponder]; Its possible to set the hidden attrribute from UITextField to YES - so the user will never see the textfield. After Keyboard input is finished you can remove the UITextField with removeFromSuperview.

Maybe a little bit dirty, but thats the solution I used often. I wonder if the SDK provide another possibility.