iOS Developer Library — Pre-Release

Developer

UIKit Framework Reference UITextInputTraits Protocol Reference

Options
Deployment Target:

On This Page
Language:

UITextInputTraits

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.

Inheritance


Not Applicable

Import Statement


Swift

import UIKit

Objective-C

@import UIKit;

Availability


Available in iOS 2.0 and later.
  • The auto-capitalization style for the text object.

    Declaration

    Swift

    optional var autocapitalizationType: UITextAutocapitalizationType { get set }

    Objective-C

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

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • The auto-correction style for the text object.

    Declaration

    Swift

    optional var autocorrectionType: UITextAutocorrectionType { get set }

    Objective-C

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

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • The spell-checking style for the text object.

    Declaration

    Swift

    optional var spellCheckingType: UITextSpellCheckingType { get set }

    Objective-C

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

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 5.0 and later.

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

    Declaration

    Swift

    optional var enablesReturnKeyAutomatically: Bool { get set }

    Objective-C

    @property(nonatomic) BOOL enablesReturnKeyAutomatically

    Discussion

    The default value for this property is NOfalse. If you set it to YEStrue, 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.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

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

    Declaration

    Swift

    optional var keyboardAppearance: UIKeyboardAppearance { get set }

    Objective-C

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

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • The keyboard style associated with the text object.

    Declaration

    Swift

    optional var keyboardType: UIKeyboardType { get set }

    Objective-C

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

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • The contents of the “return” key.

    Declaration

    Swift

    optional var returnKeyType: UIReturnKeyType { get set }

    Objective-C

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

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

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

    Declaration

    Swift

    optional var secureTextEntry: Bool { get set }

    Objective-C

    @property(nonatomic, getter=isSecureTextEntry) BOOL secureTextEntry

    Discussion

    This property is set to NOfalse by default. Setting this property to YEStrue creates a password-style text object, which hides the text being entered.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

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

    Declaration

    Swift

    enum UITextAutocapitalizationType : Int { case None case Words case Sentences case AllCharacters }

    Objective-C

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

    Constants

    • None

      UITextAutocapitalizationTypeNone

      Do not capitalize any text automatically.

      Available in iOS 2.0 and later.

    • Words

      UITextAutocapitalizationTypeWords

      Capitalize the first letter of each word automatically.

      Available in iOS 2.0 and later.

    • Sentences

      UITextAutocapitalizationTypeSentences

      Capitalize the first letter of each sentence automatically.

      Available in iOS 2.0 and later.

    • AllCharacters

      UITextAutocapitalizationTypeAllCharacters

      Capitalize all characters automatically.

      Available in iOS 2.0 and later.

    Discussion

    If the script system does not support capitalization, the keyboard input method ignores these constants.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • The auto-correction behavior of a text-based view.

    Declaration

    Swift

    enum UITextAutocorrectionType : Int { case Default case No case Yes }

    Objective-C

    typedef enum : NSInteger { UITextAutocorrectionTypeDefault, UITextAutocorrectionTypeNo, UITextAutocorrectionTypeYes, } UITextAutocorrectionType;

    Constants

    • Default

      UITextAutocorrectionTypeDefault

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

      Available in iOS 2.0 and later.

    • No

      UITextAutocorrectionTypeNo

      Disable auto-correction behavior.

      Available in iOS 2.0 and later.

    • Yes

      UITextAutocorrectionTypeYes

      Enable auto-correction behavior.

      Available in iOS 2.0 and later.

    Discussion

    If the script system does not support inline auto-correction, the keyboard input method ignores these constants.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • The spell-checking behavior of a text-based view.

    Declaration

    Swift

    enum UITextSpellCheckingType : Int { case Default case No case Yes }

    Objective-C

    typedef enum : NSInteger { UITextSpellCheckingTypeDefault, UITextSpellCheckingTypeNo, UITextSpellCheckingTypeYes, } UITextSpellCheckingType;

    Constants

    • Default

      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.

    • No

      UITextSpellCheckingTypeNo

      Disable spell-checking behavior.

      Available in iOS 5.0 and later.

    • Yes

      UITextSpellCheckingTypeYes

      Enable spell-checking behavior.

      Available in iOS 5.0 and later.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 5.0 and later.

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

    Declaration

    Swift

    enum UIKeyboardType : Int { case Default case ASCIICapable case NumbersAndPunctuation case URL case NumberPad case PhonePad case NamePhonePad case EmailAddress case DecimalPad case Twitter case WebSearch }

    Objective-C

    typedef enum : NSInteger { UIKeyboardTypeDefault, UIKeyboardTypeASCIICapable, UIKeyboardTypeNumbersAndPunctuation, UIKeyboardTypeURL, UIKeyboardTypeNumberPad, UIKeyboardTypePhonePad, UIKeyboardTypeNamePhonePad, UIKeyboardTypeEmailAddress, UIKeyboardTypeDecimalPad, UIKeyboardTypeTwitter, UIKeyboardTypeWebSearch, UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable } UIKeyboardType;

    Constants

    • Default

      UIKeyboardTypeDefault

      Use the default keyboard for the current input method.

      Available in iOS 2.0 and later.

    • ASCIICapable

      UIKeyboardTypeASCIICapable

      Use a keyboard that displays standard ASCII characters.

      Available in iOS 2.0 and later.

    • NumbersAndPunctuation

      UIKeyboardTypeNumbersAndPunctuation

      Use the numbers and punctuation keyboard.

      Available in iOS 2.0 and later.

    • URL

      UIKeyboardTypeURL

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

      Available in iOS 2.0 and later.

    • NumberPad

      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.

    • PhonePad

      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.

    • NamePhonePad

      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.

    • EmailAddress

      UIKeyboardTypeEmailAddress

      Use a keyboard optimized for specifying email addresses. This type features the “@”, “.” and space characters prominently.

      Available in iOS 2.0 and later.

    • DecimalPad

      UIKeyboardTypeDecimalPad

      Use a keyboard with numbers and a decimal point.

      Available in iOS 4.1 and later.

    • Twitter

      UIKeyboardTypeTwitter

      Use a keyboard optimized for twitter text entry, with easy access to the @ and # characters.

      Available in iOS 5.0 and later.

    • WebSearch

      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.

    • UIKeyboardTypeAlphabet

      UIKeyboardTypeAlphabet

      Use a keyboard optimized for alphabetic entry.

      Use UIKeyboardTypeASCIICapable instead.

      Available in iOS 2.0 and later.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • The appearance of the keyboard used by a text-based view.

    Declaration

    Swift

    enum UIKeyboardAppearance : Int { case Default case Dark case Light }

    Objective-C

    typedef enum : NSInteger { UIKeyboardAppearanceDefault, UIKeyboardAppearanceDark, UIKeyboardAppearanceLight, UIKeyboardAppearanceAlert, } UIKeyboardAppearance;

    Constants

    • Default

      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.

    • Dark

      UIKeyboardAppearanceDark

      Use a keyboard where a dark look is required.

      Available in iOS 7.0 and later.

    • Light

      UIKeyboardAppearanceLight

      Use a keyboard where a light look is required.

      Available in iOS 7.0 and later.

    • UIKeyboardAppearanceAlert

      UIKeyboardAppearanceAlert

      Use a keyboard that is suitable for an alert panel.

      Use UIKeyboardAppearanceDark instead.

      Available in iOS 2.0 and later.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • The text string displayed in the “return” key of a keyboard.

    Declaration

    Swift

    enum UIReturnKeyType : Int { case Default case Go case Google case Join case Next case Route case Search case Send case Yahoo case Done case EmergencyCall }

    Objective-C

    typedef enum : NSInteger { UIReturnKeyDefault, UIReturnKeyGo, UIReturnKeyGoogle, UIReturnKeyJoin, UIReturnKeyNext, UIReturnKeyRoute, UIReturnKeySearch, UIReturnKeySend, UIReturnKeyYahoo, UIReturnKeyDone, UIReturnKeyEmergencyCall, } UIReturnKeyType;

    Constants

    • Default

      UIReturnKeyDefault

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

      Available in iOS 2.0 and later.

    • Go

      UIReturnKeyGo

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

      Available in iOS 2.0 and later.

    • Google

      UIReturnKeyGoogle

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

      Available in iOS 2.0 and later.

    • Join

      UIReturnKeyJoin

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

      Available in iOS 2.0 and later.

    • Next

      UIReturnKeyNext

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

      Available in iOS 2.0 and later.

    • Route

      UIReturnKeyRoute

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

      Available in iOS 2.0 and later.

    • Search

      UIReturnKeySearch

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

      Available in iOS 2.0 and later.

    • Send

      UIReturnKeySend

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

      Available in iOS 2.0 and later.

    • Yahoo

      UIReturnKeyYahoo

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

      Available in iOS 2.0 and later.

    • Done

      UIReturnKeyDone

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

      Available in iOS 2.0 and later.

    • EmergencyCall

      UIReturnKeyEmergencyCall

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

      Available in iOS 2.0 and later.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.