iPhone OS Reference Library Apple Developer Connection spyglass button

UITextInputTraits Protocol Reference

Conforms to
Framework
/System/Library/Frameworks/UIKit.framework
Availability
Available in iPhone OS 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

For more about Objective-C properties, see “Properties” in The Objective-C Programming Language.

autocapitalizationType

The auto-capitalization style for the text object. (required)

@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 UITextAutocapitalizationTypeNone.

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
Related Sample Code
Declared In
UITextInputTraits.h

autocorrectionType

The auto-correction style for the text object. (required)

@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
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. (required)

@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
Declared In
UITextInputTraits.h

keyboardAppearance

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

@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
Declared In
UITextInputTraits.h

keyboardType

The keyboard style associated with the text object. (required)

@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
Related Sample Code
Declared In
UITextInputTraits.h

returnKeyType

The contents of the “return” key. (required)

@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
Related Sample Code
Declared In
UITextInputTraits.h

secureTextEntry

Identifies whether the text object should hide the text being entered. (required)

@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
Related Sample Code
Declared In
UITextInputTraits.h

Constants

UITextAutocapitalizationType

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

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

Do not capitalize any text automatically.

Available in iPhone OS 2.0 and later.

Declared in UITextInputTraits.h.

UITextAutocapitalizationTypeWords

Capitalize the first letter of each word automatically.

Available in iPhone OS 2.0 and later.

Declared in UITextInputTraits.h.

UITextAutocapitalizationTypeSentences

Capitalize the first letter of each sentence automatically.

Available in iPhone OS 2.0 and later.

Declared in UITextInputTraits.h.

UITextAutocapitalizationTypeAllCharacters

Capitalize all characters automatically.

Available in iPhone OS 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
UITextAutocorrectionTypeDefault

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

Available in iPhone OS 2.0 and later.

Declared in UITextInputTraits.h.

UITextAutocorrectionTypeNo

Disable auto-correction behavior.

Available in iPhone OS 2.0 and later.

Declared in UITextInputTraits.h.

UITextAutocorrectionTypeYes

Enable auto-correction behavior.

Available in iPhone OS 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.

UIKeyboardType

The type of keyboard to display for a given text-based view.

typedef enum {
   UIKeyboardTypeDefault,
   UIKeyboardTypeASCIICapable,
   UIKeyboardTypeNumbersAndPunctuation,
   UIKeyboardTypeURL,
   UIKeyboardTypeNumberPad,
   UIKeyboardTypePhonePad,
   UIKeyboardTypeNamePhonePad,
   UIKeyboardTypeEmailAddress,
   UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable
} UIKeyboardType;
Constants
UIKeyboardTypeDefault

Use the default keyboard for the current input method.

Available in iPhone OS 2.0 and later.

Declared in UITextInputTraits.h.

UIKeyboardTypeASCIICapable

Use a keyboard that displays standard ASCII characters.

Available in iPhone OS 2.0 and later.

Declared in UITextInputTraits.h.

UIKeyboardTypeNumbersAndPunctuation

Use the numbers and punctuation keyboard.

Available in iPhone OS 2.0 and later.

Declared in UITextInputTraits.h.

UIKeyboardTypeURL

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

Available in iPhone OS 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 iPhone OS 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 iPhone OS 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 iPhone OS 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 iPhone OS 2.0 and later.

Declared in UITextInputTraits.h.

UIKeyboardTypeAlphabet

Deprecated.

Use UIKeyboardTypeASCIICapable instead.

Available in iPhone OS 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
UIKeyboardAppearanceDefault

Use the default keyboard appearance for the current input method.

Available in iPhone OS 2.0 and later.

Declared in UITextInputTraits.h.

UIKeyboardAppearanceAlert

Use a keyboard that is suitable for an alert panel.

Available in iPhone OS 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
UIReturnKeyDefault

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

Available in iPhone OS 2.0 and later.

Declared in UITextInputTraits.h.

UIReturnKeyGo

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

Available in iPhone OS 2.0 and later.

Declared in UITextInputTraits.h.

UIReturnKeyGoogle

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

Available in iPhone OS 2.0 and later.

Declared in UITextInputTraits.h.

UIReturnKeyJoin

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

Available in iPhone OS 2.0 and later.

Declared in UITextInputTraits.h.

UIReturnKeyNext

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

Available in iPhone OS 2.0 and later.

Declared in UITextInputTraits.h.

UIReturnKeyRoute

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

Available in iPhone OS 2.0 and later.

Declared in UITextInputTraits.h.

UIReturnKeySearch

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

Available in iPhone OS 2.0 and later.

Declared in UITextInputTraits.h.

UIReturnKeySend

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

Available in iPhone OS 2.0 and later.

Declared in UITextInputTraits.h.

UIReturnKeyYahoo

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

Available in iPhone OS 2.0 and later.

Declared in UITextInputTraits.h.

UIReturnKeyDone

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

Available in iPhone OS 2.0 and later.

Declared in UITextInputTraits.h.

UIReturnKeyEmergencyCall

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

Available in iPhone OS 2.0 and later.

Declared in UITextInputTraits.h.



Last updated: 2009-08-04

Did this document help you? Yes It's good, but... Not helpful...