zaph
zaph

Reputation: 112873

TextField Keyboard startup in Number mode

I need the UITextField "ASCII Capable" keyboard to come up in numeric mode. I can't find an API for this, what am I missing?

Upvotes: 8

Views: 6195

Answers (3)

Jeff Kelley
Jeff Kelley

Reputation: 19071

Assuming you have a UITextField named textField, all you need to do is call the method:

[ textField setKeyboardType:UIKeyboardTypeNumbersAndPunctuation ];

You may need to call this before the keyboard is displayed.

Upvotes: 11

Jay
Jay

Reputation: 320

Are you using Interface Builder? If so, click on the text field, then go to the Text Field Attributes. There will be an attribute for Keyboard. Change it to Number Pad.

Upvotes: -1

John Stallings
John Stallings

Reputation: 581

from the documentation does this help?

The appearance of the keyboard itself can be customized using the properties provided by the UITextInputTraits protocol. Text field objects implement this protocol and support the properties it defines. You can use these properties to specify the type of keyboard (ASCII, Numbers, URL, Email, and others) to display. You can also configure the basic text entry behavior of the keyboard, such as whether it supports automatic capitalization and correction of the text.

Upvotes: 0

Related Questions