When I start editing a UITextField, I have the "Clear When Editing Begins" option checked so it starts off with no text. However, the "Return" button is grayed out until you type at least one character.
I've seen other iphone apps where the "Return" button is not grayed out (and if you press it with no text, then it goes back to what the text used to be). How is this done?
Thanks.
Type in the text as you desire and when you're reading to insert a line break, tap on the “123” key at the bottom-left of the keyboard. This will give you access to the num pad. Here, you'll find the “return” key at the bottom-right corner of the keyboard, next to the space bar.
In most cases, you can just find the Enter key on the keyboard. It usually happens to the Windows computer because Microsoft Windows treats these two keys the same. When you want to use the return key, you can just try the Enter key.
UITextView and UITextField implement the UITextInputTraits Protocol. The protocol specifies a property called enablesReturnKeyAutomatically
. Here's the description from the UITextInputTraits reference:
The default value for this property is NO. If you set it to YES, the keyboard disables the return key when the text entry area contains no text. As soon as the user enters any text, the return key is automatically enabled.
So, setting the property to NO after loading the TextField should do the trick.
Interface Builder folks uncheck Auto-enable Return Key in Attributes Inspector. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With