UITextInputTraits Protocol Reference
| Conforms to | |
| Framework | /System/Library/Frameworks/UIKit.framework |
| Availability | Available in iOS 2.0 and later. |
| Declared in | UITextInputTraits.h |
Overview
The UITextInputTraits protocol defines features that are associated with keyboard input. All objects that support keyboard input must adopt this protocol in order to interact properly with the text input management system. The UITextField and UITextView classes already support this protocol.
Tasks
Managing the Keyboard Behavior
-
autocapitalizationTyperequired property -
autocorrectionTyperequired property -
spellCheckingTyperequired property -
enablesReturnKeyAutomaticallyrequired property -
keyboardAppearancerequired property -
keyboardTyperequired property -
returnKeyTyperequired property -
secureTextEntryrequired property
Properties
autocapitalizationType
The auto-capitalization style for the text object. (required)
Discussion
This property determines at what times the Shift key is automatically pressed, thereby making the typed character a capital letter. The default value for this property is UITextAutocapitalizationTypeSentences.
Some keyboard types do not support auto-capitalization. Specifically, this option is ignored if the value in the keyboardType property is set to UIKeyboardTypeNumberPad, UIKeyboardTypePhonePad, or UIKeyboardTypeNamePhonePad.
Availability
- Available in iOS 2.0 and later.
Declared In
UITextInputTraits.hautocorrectionType
The auto-correction style for the text object. (required)
Discussion
This property determines whether auto-correction is enabled or disabled during typing. With auto-correction enabled, the text object tracks unknown words and suggests a more suitable replacement candidate to the user, replacing the typed text automatically unless the user explicitly overrides the action.
The default value for this property is UITextAutocorrectionTypeDefault, which for most input methods results in auto-correction being enabled.
Availability
- Available in iOS 2.0 and later.
Declared In
UITextInputTraits.henablesReturnKeyAutomatically
A Boolean value indicating whether the return key is automatically enabled when text is entered by the user. (required)
Discussion
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.
Availability
- Available in iOS 2.0 and later.
Declared In
UITextInputTraits.hkeyboardAppearance
The appearance style of the keyboard that is associated with the text object (required)
Discussion
This property lets you distinguish between the default text entry inside your application and text entry inside an alert panel. The default value for this property is UIKeyboardAppearanceDefault.
Availability
- Available in iOS 2.0 and later.
Declared In
UITextInputTraits.hkeyboardType
The keyboard style associated with the text object. (required)
Discussion
Text objects can be targeted for specific types of input, such as plain text, email, numeric entry, and so on. The keyboard style identifies what keys are available on the keyboard and which ones appear by default. The default value for this property is UIKeyboardTypeDefault.
Availability
- Available in iOS 2.0 and later.
Declared In
UITextInputTraits.hreturnKeyType
The contents of the “return” key. (required)
Discussion
Setting this property to a different key type changes the title of the key and typically results in the keyboard being dismissed when it is pressed. The default value for this property is UIReturnKeyDefault.
Availability
- Available in iOS 2.0 and later.
Declared In
UITextInputTraits.hsecureTextEntry
Identifies whether the text object should hide the text being entered. (required)
Discussion
This property is set to NO by default. Setting this property to YES creates a password-style text object, which hides the text being entered.
Availability
- Available in iOS 2.0 and later.
Declared In
UITextInputTraits.hspellCheckingType
The spell-checking style for the text object. (required)
Discussion
This property determines whether spell-checking is enabled or disabled during typing. With spell-checking enabled, the text object generates red underlines for all misspelled words. If the user taps on a misspelled word, the text object presents the user with a list of possible corrections.
The default value for this property is UITextSpellCheckingTypeDefault, which enables spell-checking when auto-correction is also enabled. The value in this property supersedes the spell-checking setting set by the user in Settings > General > Keyboard.
Availability
- Available in iOS 5.0 and later.
Declared In
UITextInputTraits.hConstants
UITextAutocapitalizationType
The auto-capitalization behavior of a text-based view.
typedef enum {
UITextAutocapitalizationTypeNone,
UITextAutocapitalizationTypeWords,
UITextAutocapitalizationTypeSentences,
UITextAutocapitalizationTypeAllCharacters,
} UITextAutocapitalizationType;
Constants
UITextAutocapitalizationTypeNoneDo not capitalize any text automatically.
Available in iOS 2.0 and later.
Declared in
UITextInputTraits.h.UITextAutocapitalizationTypeWordsCapitalize the first letter of each word automatically.
Available in iOS 2.0 and later.
Declared in
UITextInputTraits.h.UITextAutocapitalizationTypeSentencesCapitalize the first letter of each sentence automatically.
Available in iOS 2.0 and later.
Declared in
UITextInputTraits.h.UITextAutocapitalizationTypeAllCharactersCapitalize all characters automatically.
Available in iOS 2.0 and later.
Declared in
UITextInputTraits.h.
Discussion
If the script system does not support capitalization, the keyboard input method ignores these constants.
UITextAutocorrectionType
The auto-correction behavior of a text-based view.
typedef enum {
UITextAutocorrectionTypeDefault,
UITextAutocorrectionTypeNo,
UITextAutocorrectionTypeYes,
} UITextAutocorrectionType;
Constants
UITextAutocorrectionTypeDefaultChoose an appropriate auto-correction behavior for the current script system.
Available in iOS 2.0 and later.
Declared in
UITextInputTraits.h.UITextAutocorrectionTypeNoDisable auto-correction behavior.
Available in iOS 2.0 and later.
Declared in
UITextInputTraits.h.UITextAutocorrectionTypeYesEnable auto-correction behavior.
Available in iOS 2.0 and later.
Declared in
UITextInputTraits.h.
Discussion
If the script system does not support inline auto-correction, the keyboard input method ignores these constants.
UITextSpellCheckingType
The spell-checking behavior of a text-based view.
typedef enum {
UITextSpellCheckingTypeDefault,
UITextSpellCheckingTypeNo,
UITextSpellCheckingTypeYes,
} UITextSpellCheckingType;
Constants
UITextSpellCheckingTypeDefaultUse the default spell-checking behavior. The default behavior is to enable spell-checking whenever auto-correction is also enabled.
Available in iOS 5.0 and later.
Declared in
UITextInputTraits.h.UITextSpellCheckingTypeNoDisable spell-checking behavior.
Available in iOS 5.0 and later.
Declared in
UITextInputTraits.h.UITextSpellCheckingTypeYesEnable spell-checking behavior.
Available in iOS 5.0 and later.
Declared in
UITextInputTraits.h.
UIKeyboardType
The type of keyboard to display for a given text-based view.
typedef enum {
UIKeyboardTypeDefault,
UIKeyboardTypeASCIICapable,
UIKeyboardTypeNumbersAndPunctuation,
UIKeyboardTypeURL,
UIKeyboardTypeNumberPad,
UIKeyboardTypePhonePad,
UIKeyboardTypeNamePhonePad,
UIKeyboardTypeEmailAddress,
UIKeyboardTypeDecimalPad,
UIKeyboardTypeTwitter,
UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable
} UIKeyboardType;
Constants
UIKeyboardTypeDefaultUse the default keyboard for the current input method.
Available in iOS 2.0 and later.
Declared in
UITextInputTraits.h.UIKeyboardTypeASCIICapableUse a keyboard that displays standard ASCII characters.
Available in iOS 2.0 and later.
Declared in
UITextInputTraits.h.UIKeyboardTypeNumbersAndPunctuationUse the numbers and punctuation keyboard.
Available in iOS 2.0 and later.
Declared in
UITextInputTraits.h.UIKeyboardTypeURLUse a keyboard optimized for URL entry. This type features “.”, “/”, and “.com” prominently.
Available in iOS 2.0 and later.
Declared in
UITextInputTraits.h.UIKeyboardTypeNumberPadUse a numeric keypad designed for PIN entry. This type features the numbers 0 through 9 prominently. This keyboard type does not support auto-capitalization.
Available in iOS 2.0 and later.
Declared in
UITextInputTraits.h.UIKeyboardTypePhonePadUse a keypad designed for entering telephone numbers. This type features the numbers 0 through 9 and the “*” and “#” characters prominently. This keyboard type does not support auto-capitalization.
Available in iOS 2.0 and later.
Declared in
UITextInputTraits.h.UIKeyboardTypeNamePhonePadUse a keypad designed for entering a person’s name or phone number. This keyboard type does not support auto-capitalization.
Available in iOS 2.0 and later.
Declared in
UITextInputTraits.h.UIKeyboardTypeEmailAddressUse a keyboard optimized for specifying email addresses. This type features the “@”, “.” and space characters prominently.
Available in iOS 2.0 and later.
Declared in
UITextInputTraits.h.UIKeyboardTypeDecimalPadUse a keyboard with numbers and a decimal point.
Available in iOS 4.1 and later.
Declared in
UITextInputTraits.h.UIKeyboardTypeTwitterUse a keyboard optimized for twitter text entry, with easy access to the
@and#characters.Available in iOS 5.0 and later.
Declared in
UITextInputTraits.h.UIKeyboardTypeAlphabetDeprecated.
Use
UIKeyboardTypeASCIICapableinstead.Available in iOS 2.0 and later.
Declared in
UITextInputTraits.h.
UIKeyboardAppearance
The appearance of the keyboard used by a text-based view.
typedef enum {
UIKeyboardAppearanceDefault,
UIKeyboardAppearanceAlert,
} UIKeyboardAppearance;
Constants
UIKeyboardAppearanceDefaultUse the default keyboard appearance for the current input method.
Available in iOS 2.0 and later.
Declared in
UITextInputTraits.h.UIKeyboardAppearanceAlertUse a keyboard that is suitable for an alert panel.
Available in iOS 2.0 and later.
Declared in
UITextInputTraits.h.
UIReturnKeyType
The text string displayed in the “return” key of a keyboard.
typedef enum {
UIReturnKeyDefault,
UIReturnKeyGo,
UIReturnKeyGoogle,
UIReturnKeyJoin,
UIReturnKeyNext,
UIReturnKeyRoute,
UIReturnKeySearch,
UIReturnKeySend,
UIReturnKeyYahoo,
UIReturnKeyDone,
UIReturnKeyEmergencyCall,
} UIReturnKeyType;
Constants
UIReturnKeyDefaultSet the text of the return key to “return”.
Available in iOS 2.0 and later.
Declared in
UITextInputTraits.h.UIReturnKeyGoSet the text of the return key to “Go”.
Available in iOS 2.0 and later.
Declared in
UITextInputTraits.h.UIReturnKeyGoogleSet the text of the return key to “Google”.
Available in iOS 2.0 and later.
Declared in
UITextInputTraits.h.UIReturnKeyJoinSet the text of the return key to “Join”.
Available in iOS 2.0 and later.
Declared in
UITextInputTraits.h.UIReturnKeyNextSet the text of the return key to “Next”.
Available in iOS 2.0 and later.
Declared in
UITextInputTraits.h.UIReturnKeyRouteSet the text of the return key to “Route”.
Available in iOS 2.0 and later.
Declared in
UITextInputTraits.h.UIReturnKeySearchSet the text of the return key to “Search”.
Available in iOS 2.0 and later.
Declared in
UITextInputTraits.h.UIReturnKeySendSet the text of the return key to “Send”.
Available in iOS 2.0 and later.
Declared in
UITextInputTraits.h.UIReturnKeyYahooSet the text of the return key to “Yahoo”.
Available in iOS 2.0 and later.
Declared in
UITextInputTraits.h.UIReturnKeyDoneSet the text of the return key to “Done”.
Available in iOS 2.0 and later.
Declared in
UITextInputTraits.h.UIReturnKeyEmergencyCallSet the text of the return key to “Emergency Call”.
Available in iOS 2.0 and later.
Declared in
UITextInputTraits.h.
© 2011 Apple Inc. All Rights Reserved. (Last updated: 2011-10-12)