swift - iOS12 中文键盘(zh-Hans 和 zh-Hant)导致应用崩溃(TextFiled in UISearchBar/UIAlertView/UIAlertViewController)
问题描述
我的应用升级到 iOS 12 后出现此问题。每当调用原生中文键盘或第三方中文键盘时,应用都会崩溃。中文手写键盘不会导致死机。
该应用程序已本地化为英文和中文,因此 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 扩展来修复崩溃。
推荐阅读
- mysql - 在 `__in` 中的列表中包含一项的查询非常慢。否则,超级快
- python - 处理两个不同月份的两个日期的计算
- node.js - 使用 mongoose 在 mongodb 中存储 ArrayBuffer
- firebase - 无法使用链接到 Squarespace 的自定义域设置动态链接
- python - python:类函数返回值但不可用
- magento - 无法打开 magento 1.9 管理面板
- mysql - 如何在价格历史表中删除所有产品但保留 N 个最新行
- c - 如何知道哪个线程正在执行一个函数?
- node.js - 使用来自 localhost:8081 的请求对象从 NodeJs app.post 调用 localhost:8080 payara 服务器不起作用
- microsoft-graph-api - 存档邮箱的图形 API 失败