By ahmad

2012-07-08 11:24:29 8 Comments

is it possible to change the keyboard layout to emoji when a UITextField becomes the first responder ? or according to a user action like tapping a UIButton

i know that i can change the keyboard layout to one of these

typedef enum {
UIKeyboardTypeDefault,                // Default type for the current input method.
UIKeyboardTypeASCIICapable,           // Displays a keyboard which can enter ASCII characters, non-ASCII keyboards remain active
UIKeyboardTypeNumbersAndPunctuation,  // Numbers and assorted punctuation.
UIKeyboardTypeURL,                    // A type optimized for URL entry (shows . / .com prominently).
UIKeyboardTypeNumberPad,              // A number pad (0-9). Suitable for PIN entry.
UIKeyboardTypePhonePad,               // A phone pad (1-9, *, 0, #, with letters under the numbers).
UIKeyboardTypeNamePhonePad,           // A type optimized for entering a person's name or phone number.
UIKeyboardTypeEmailAddress,           // A type optimized for multiple email address entry (shows space @ . prominently).

UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable, // Deprecated

} UIKeyboardType;

I am wondering if there's a way to do the same with the emoji layout


@Dale 2017-06-26 05:51:51

Create a subclass of UITextField like this:

class EmojiTextField: UITextField {

    override var textInputMode: UITextInputMode? {
        for mode in UITextInputMode.activeInputModes {
            if mode.primaryLanguage == "emoji" {
                return mode
        return nil

In IB select this class as the Custom Class in place of UITextField.

This causes the keyboard to select emoji keyboard, if available, when the field becomes first responder. The user can, of course, change the keyboard back to anything else at any time, but at least it gives an initial selection of what you want.

@inorganik 2017-07-07 20:19:19

yes, this!!!11!

@Fadi Abuzant 2018-02-02 20:21:27

Helpful trick thanks man 👍🏻

@Demosthese 2018-07-06 21:27:37

That's just perfect

Related Questions

Sponsored Content

26 Answered Questions

39 Answered Questions

[SOLVED] Move view with keyboard using Swift

36 Answered Questions

[SOLVED] Close iOS Keyboard by touching anywhere using Swift

  • 2014-06-09 18:38:10
  • lagoon
  • 305276 View
  • 351 Score
  • 36 Answer
  • Tags:   ios swift uikeyboard

91 Answered Questions

33 Answered Questions

[SOLVED] How to change the name of an iOS app?

  • 2008-10-27 03:07:03
  • Robert Gould
  • 440992 View
  • 940 Score
  • 33 Answer
  • Tags:   ios

35 Answered Questions

[SOLVED] iOS - Dismiss keyboard when touching outside of UITextField

6 Answered Questions

1 Answered Questions

[SOLVED] Custom Number Pad For iPad App

1 Answered Questions

UIKeyboardType overridden by default keyboard for language?

1 Answered Questions

[SOLVED] Change UIKeyboardType based on text input

Sponsored Content