默认情况下,在iOS 13上显示系统Emoji键盘 [英] Showing the system Emoji keyboard by default on iOS 13

查看:827
本文介绍了默认情况下,在iOS 13上显示系统Emoji键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

解决方案

以下是此问题的完整解决方案/工作,请对Blld的

Here is a full solution/work around for this issue, please up vote Blld's answer as well because this was the vital bit of info needed!

辅助搜索的标题

  • 将Emoji键盘默认显示为UIKeyInput对象(在iOS 13中)
  • 强制iOS 13显示表情符号键盘
  • UITextInputMode.primaryLanguage设置为表情符号
  • 以编程方式将键盘设置为表情符号
  • Showing the Emoji keyboard as default for a UIKeyInput object (in iOS 13)
  • Force iOS 13 to show the Emoji keyboard
  • Setting the UITextInputMode.primaryLanguage to emoji
  • Programatically set the keyboard to emoji

的问题,返回UITextInputMode primaryLanguage等于表情符号"的情况下,默认情况下将显示表情符号键盘(请参见下图).

Prior to ios13 returning the UITextInputMode with primaryLanguage that equaled "emoji" would default to showing the Emoji Keyboard (see image below).

用于返回表情符号" UITextInputMode的示例代码.

Example code for returning the "emoji" UITextInputMode.

//
//  ViewController.swift
//  Keyboard Info
//
//  Created by Richard Stelling on 30/09/2019.
//  Copyright © 2019 Richard Stelling. All rights reserved.
//

import UIKit

class TestButton: UIButton, UIKeyInput {

    var hasText: Bool = true

    func insertText(_ text: String) { print("\(text)") }

    func deleteBackward() {}


    override var canBecomeFirstResponder: Bool { return true }

    override var canResignFirstResponder: Bool { return true }

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

在iOS 12上运行此代码会将键盘设置为系统Emoji键盘,但在iOS 13上则无效.

Running this code on iOS 12 will set the keyboard to the system Emoji Keyboard, but on iOS 13 it has no affect.

这是一个已知的错误吗?有解决方法吗?

Is this a known bug? Is there a workaround?

更新

  • @Navillus 的请求,活动输入模式"的完整列表为; "en-GB","emoji"
  • 经过测试并确认; 13.0、13.1、13.1.1、13.1.2和13.2(种子1)
  • Requested by @Navillus, the full list of "active input modes" is; "en-GB", "emoji"
  • Tested and confirmed on; 13.0, 13.1, 13.1.1, 13.1.2 and 13.2 (seed 1)

推荐答案

注意:请确保已启用表情符号键盘.

NB: Make sure you have the Emoji keyboard enabled.

这似乎是iOS 13的错误,解决方法(对于设备,这不影响模拟器)是覆盖textInputContextIdentifier属性并返回非null值.

This seems to be an iOS 13 bug, the work around (for devices, this does not affect the Simulator) is to override the textInputContextIdentifier property and return a non-nil value.

//
//  ViewController.swift
//  Keyboard Info
//
//  Created by Richard Stelling on 30/09/2019.
//  Copyright © 2019 Richard Stelling. All rights reserved.
//

import UIKit

class TestButton: UIButton, UIKeyInput {

    var hasText: Bool = true

    override var textInputContextIdentifier: String? { "" } // return non-nil to show the Emoji keyboard ¯\_(ツ)_/¯ 

    func insertText(_ text: String) { print("\(text)") }

    func deleteBackward() {}

    override var canBecomeFirstResponder: Bool { return true }

    override var canResignFirstResponder: Bool { return true }

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

感谢 blld 的答案.

这篇关于默认情况下,在iOS 13上显示系统Emoji键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆