swift - iOS12 中文键盘(zh-Hans 和 zh-Hant)导致应用程序崩溃(UISearchBar/UIAlertView/UIAlertViewController 中的 TextFiled)

标签 swift uisearchbar textfield uialertview ios12

我的应用程序在升级到 iOS 12 后出现此问题。每当调用 native 中文键盘或第三方中文键盘时,应用程序都会崩溃。中文手写键盘不会导致崩溃。

该应用程序已本地化为英语和中文,因此 UserDefaults 中的“AppleLanguages”会随着用户的修改而随时更改。

用于 searchBar 的代码很简单。

@IBOutlet weak var searchBar: UISearchBar!
self.searchBar.delegate = self

异常消息是:

-[NSNull isSecureContentCandidate]: unrecognized selector sent to instance 0x1e39f99a0 * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull isSecureContentCandidate]: unrecognized selector sent to instance 0x1e39f99a0' * First throw call stack: (0x1b3ce3ef8 0x1b2eb1a40 0x1b3bfb154 0x1b3ce9810 0x1b3ceb4bc 0x1e030ed18 0x1e039472c 0x1e0394380 0x1e03e7030 0x1e0394330 0x1e03e9064 0x1e03e7774 0x1e03e7784 0x1b47935a0 0x1b3c725b8 0x1b3c72538 0x1b3c71e1c 0x1b3c6cce8 0x1b3c6c5b8 0x1b5ee0584 0x1e0567558 0x100575d34 0x1b372cb94) libc++abi.dylib: terminating with uncaught exception of type NSException

我尝试通过强制应用程序使用字母键盘来解决崩溃问题,这会禁用存在此问题的页面的中文输入。

self.searchBar.keyboardType = UIKeyboardType.alphabet

先谢谢你了~!

最佳答案

通过调整本地 NSNull 扩展修复了崩溃。

关于swift - iOS12 中文键盘(zh-Hans 和 zh-Hant)导致应用程序崩溃(UISearchBar/UIAlertView/UIAlertViewController 中的 TextFiled),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52312127/

相关文章:

arrays - UITableView SearchBar过滤查询

objective-c - 隐藏 UISearchBar 取消按钮

Swiftui - 禁用键盘在 TextField 中显示

ios - 如何以编程方式禁用预测 View 但在 iOS 中的 TextView 上启用自动更正?

regex - hh :mm:ss format in TextFormField or TextField without using pickers 中的 Flutter 输入时间

swift - didReceiveRemoteNotification 未调用 swift 3 iOS 10

ios - Swift - 如何在收到推送通知时打开特定的 View Controller ?

ios - 使用 UIBarButtonItem 将 UISearchBar 添加到 UINavigationBar

ios - 核心数据关系问题

ios - 可调整大小的 UIView