enabling the “return button” in a UITextField keyboard (objective-c/iphone)

By | January 12, 2018

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?



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. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *