开发者

How to enable the "return button" in a UITextField keyboard?

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 app开发者_StackOverflows 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. :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜