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

Properties

autocapitalizationType

The auto-capitalization style for the text object.

@property(nonatomic) UITextAutocapitalizationType autocapitalizationType
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.
Related Sample Code
Declared In
UITextInputTraits.h

autocorrectionType

The auto-correction style for the text object.

@property(nonatomic) UITextAutocorrectionType autocorrectionType
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.
Related Sample Code
Declared In
UITextInputTraits.h

enablesReturnKeyAutomatically

A Boolean value indicating whether the return key is automatically enabled when text is entered by the user.

@property(nonatomic) BOOL enablesReturnKeyAutomatically
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.h

keyboardAppearance

The appearance style of the keyboard that is associated with the text object

@property(nonatomic) UIKeyboardAppearance keyboardAppearance
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.h

keyboardType

The keyboard style associated with the text object.

@property(nonatomic) UIKeyboardType keyboardType
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.
Related Sample Code
Declared In
UITextInputTraits.h

returnKeyType

The contents of the “return” key.

@property(nonatomic) UIReturnKeyType returnKeyType
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.
Related Sample Code
Declared In
UITextInputTraits.h

secureTextEntry

Identifies whether the text object should hide the text being entered.

@property(nonatomic, getter=isSecureTextEntry) BOOL secureTextEntry
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.
Related Sample Code
Declared In
UITextInputTraits.h

spellCheckingType

The spell-checking style for the text object.

@property(nonatomic) UITextSpellCheckingType spellCheckingType
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.h

Constants

UITextAutocapitalizationType

The auto-capitalization behavior of a text-based view.

typedef enum : NSInteger {
   UITextAutocapitalizationTypeNone,
   UITextAutocapitalizationTypeWords,
   UITextAutocapitalizationTypeSentences,
   UITextAutocapitalizationTypeAllCharacters,
} UITextAutocapitalizationType;
Constants
UITextAutocapitalizationTypeNone

Do not capitalize any text automatically.

Available in iOS 2.0 and later.

Declared in UITextInputTraits.h.

UITextAutocapitalizationTypeWords

Capitalize the first letter of each word automatically.

Available in iOS 2.0 and later.

Declared in UITextInputTraits.h.

UITextAutocapitalizationTypeSentences

Capitalize the first letter of each sentence automatically.

Available in iOS 2.0 and later.

Declared in UITextInputTraits.h.

UITextAutocapitalizationTypeAllCharacters

Capitalize 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 : NSInteger {
   UITextAutocorrectionTypeDefault,
   UITextAutocorrectionTypeNo,
   UITextAutocorrectionTypeYes,
} UITextAutocorrectionType;
Constants
UITextAutocorrectionTypeDefault

Choose an appropriate auto-correction behavior for the current script system.

Available in iOS 2.0 and later.

Declared in UITextInputTraits.h.

UITextAutocorrectionTypeNo

Disable auto-correction behavior.

Available in iOS 2.0 and later.

Declared in UITextInputTraits.h.

UITextAutocorrectionTypeYes

Enable 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 : NSInteger {
   UITextSpellCheckingTypeDefault,
   UITextSpellCheckingTypeNo,
   UITextSpellCheckingTypeYes,
} UITextSpellCheckingType;
Constants
UITextSpellCheckingTypeDefault

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

UITextSpellCheckingTypeNo

Disable spell-checking behavior.

Available in iOS 5.0 and later.

Declared in UITextInputTraits.h.

UITextSpellCheckingTypeYes

Enable 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 : NSInteger {
   UIKeyboardTypeDefault,
   UIKeyboardTypeASCIICapable,
   UIKeyboardTypeNumbersAndPunctuation,
   UIKeyboardTypeURL,
   UIKeyboardTypeNumberPad,
   UIKeyboardTypePhonePad,
   UIKeyboardTypeNamePhonePad,
   UIKeyboardTypeEmailAddress,
   UIKeyboardTypeDecimalPad,
   UIKeyboardTypeTwitter,
   UIKeyboardTypeWebSearch,
   UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable
} UIKeyboardType;
Constants
UIKeyboardTypeDefault

Use the default keyboard for the current input method.

Available in iOS 2.0 and later.

Declared in UITextInputTraits.h.

UIKeyboardTypeASCIICapable

Use a keyboard that displays standard ASCII characters.

Available in iOS 2.0 and later.

Declared in UITextInputTraits.h.

UIKeyboardTypeNumbersAndPunctuation

Use the numbers and punctuation keyboard.

Available in iOS 2.0 and later.

Declared in UITextInputTraits.h.

UIKeyboardTypeURL

Use a keyboard optimized for URL entry. This type features “.”, “/”, and “.com” prominently.

Available in iOS 2.0 and later.

Declared in UITextInputTraits.h.

UIKeyboardTypeNumberPad

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

UIKeyboardTypePhonePad

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

UIKeyboardTypeNamePhonePad

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

UIKeyboardTypeEmailAddress

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

UIKeyboardTypeDecimalPad

Use a keyboard with numbers and a decimal point.

Available in iOS 4.1 and later.

Declared in UITextInputTraits.h.

UIKeyboardTypeTwitter

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

UIKeyboardTypeWebSearch

Use a keyboard optimized for web search terms and URL entry. This type features the space and “.” characters prominently.

Available in iOS 7.0 and later.

Declared in UITextInputTraits.h.

UIKeyboardTypeAlphabet

Use a keyboard optimized for alphabetic entry. (Deprecated. Use UIKeyboardTypeASCIICapable instead.)

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 : NSInteger {
   UIKeyboardAppearanceDefault,
   UIKeyboardAppearanceDark,
   UIKeyboardAppearanceLight,
   UIKeyboardAppearanceAlert,
} UIKeyboardAppearance;
Constants
UIKeyboardAppearanceDefault

Use the default keyboard appearance for the current input method. This constant corresponds to the UIKeyboardAppearanceLight value.

Available in iOS 2.0 and later.

Declared in UITextInputTraits.h.

UIKeyboardAppearanceDark

Use a keyboard where a dark look is required.

Available in iOS 7.0 and later.

Declared in UITextInputTraits.h.

UIKeyboardAppearanceLight

Use a keyboard where a light look is required.

Available in iOS 7.0 and later.

Declared in UITextInputTraits.h.

UIKeyboardAppearanceAlert

Use a keyboard that is suitable for an alert panel. (Deprecated. Use UIKeyboardAppearanceDark instead.)

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 : NSInteger {
   UIReturnKeyDefault,
   UIReturnKeyGo,
   UIReturnKeyGoogle,
   UIReturnKeyJoin,
   UIReturnKeyNext,
   UIReturnKeyRoute,
   UIReturnKeySearch,
   UIReturnKeySend,
   UIReturnKeyYahoo,
   UIReturnKeyDone,
   UIReturnKeyEmergencyCall,
} UIReturnKeyType;
Constants
UIReturnKeyDefault

Set the text of the return key to “return”.

Available in iOS 2.0 and later.

Declared in UITextInputTraits.h.

UIReturnKeyGo

Set the text of the return key to “Go”.

Available in iOS 2.0 and later.

Declared in UITextInputTraits.h.

UIReturnKeyGoogle

Set the text of the return key to “Google”.

Available in iOS 2.0 and later.

Declared in UITextInputTraits.h.

UIReturnKeyJoin

Set the text of the return key to “Join”.

Available in iOS 2.0 and later.

Declared in UITextInputTraits.h.

UIReturnKeyNext

Set the text of the return key to “Next”.

Available in iOS 2.0 and later.

Declared in UITextInputTraits.h.

UIReturnKeyRoute

Set the text of the return key to “Route”.

Available in iOS 2.0 and later.

Declared in UITextInputTraits.h.

UIReturnKeySearch

Set the text of the return key to “Search”.

Available in iOS 2.0 and later.

Declared in UITextInputTraits.h.

UIReturnKeySend

Set the text of the return key to “Send”.

Available in iOS 2.0 and later.

Declared in UITextInputTraits.h.

UIReturnKeyYahoo

Set the text of the return key to “Yahoo”.

Available in iOS 2.0 and later.

Declared in UITextInputTraits.h.

UIReturnKeyDone

Set the text of the return key to “Done”.

Available in iOS 2.0 and later.

Declared in UITextInputTraits.h.

UIReturnKeyEmergencyCall

Set the text of the return key to “Emergency Call”.

Available in iOS 2.0 and later.

Declared in UITextInputTraits.h.