1

我的应用中有两种本地化版本(英语和阿拉伯语)。我已将许多 UITextFields 的键盘类型设置为decimalPad我需要对这些字段强制使用英文小数点。但是当应用程序语言为阿拉伯语时,键盘显示为阿拉伯语。通过继承 UITextField 并覆盖textInputMode ,它可以正常工作到 iOS 12 。这是代码:

override var textInputMode: UITextInputMode? {
    for mode in UITextInputMode.activeInputModes {
        if mode.primaryLanguage?.containsSubString(subString: "en") {
            return mode
        }
    }
    return nil
}

在 iOS 13 中,上述代码无效。我在 iOS 13 上默认遵循Showing the system Emoji keyboard 。覆盖 textInputContextIdentifier 但仍然没有成功。

override var textInputContextIdentifier: String? { return "en-US" }

PS:它适用于其他键盘类型 - 数字、Asci 等。问题仅发生在小数点上。

4

0 回答 0