iOS Developer Library

Developer

UIKit Framework Reference UIKeyInput Protocol Reference

Options
Deployment Target:

On This Page
Language:

UIKeyInput

Inheritance


Not Applicable

Conforms To


Import Statement


Swift

import UIKit

Objective-C

@import UIKit;

Availability


Available in iOS 3.2 and later.

A subclass of UIResponder can adopt this protocol to implement simple text entry. When instances of this subclass are the first responder, the system keyboard is displayed.

Only a small subset of the available keyboards and languages are available to classes that adopt this protocol.

  • Insert a character into the displayed text. (required)

    Declaration

    Swift

    func insertText(_ text: String)

    Objective-C

    - (void)insertText:(NSString *)text

    Parameters

    text

    A string object representing the character typed on the system keyboard.

    Discussion

    Add the character text to your class’s backing store at the index corresponding to the cursor and redisplay the text.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 3.2 and later.

  • Delete a character from the displayed text. (required)

    Declaration

    Swift

    func deleteBackward()

    Objective-C

    - (void)deleteBackward

    Discussion

    Remove the character just before the cursor from your class’s backing store and redisplay the text.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 3.2 and later.

  • hasText() - hasText Required

    A Boolean value that indicates whether the text-entry objects has any text. (required)

    Declaration

    Swift

    func hasText() -> Bool

    Objective-C

    - (BOOL)hasText

    Return Value

    YEStrue if the backing store has textual content, NOfalse otherwise.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 3.2 and later.