溶液
这是一个关于这个问题的全面解决办法/工作,请投票给Blld的回答,因为这是所需的重要信息!
辅助搜索的替代标题
UITextInputMode.primaryLanguage
设置为emoji在ios13之前,返回与primaryLanguage
相同的“表情符号”的UITextInputMode
将默认显示Emoji键盘(见下图)。
返回"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上它不会产生任何影响。
这是已知的窃听器吗?有解决办法吗?
更新
发布于 2019-10-24 08:45:07
您需要在textinputcontextidentifier
上设置textField,以便iOS知道在哪里保存自定义textInputMode
它不是在文档中写的,但它有效。
参考文献:https://developer.apple.com/documentation/uikit/uiresponder/1621091-textinputcontextidentifier
https://stackoverflow.com/questions/58168017
复制相似问题