【发布时间】:2020-12-22 16:17:50
【问题描述】:
在 iPad 应用程序中遇到此错误。在文本字段中将出现键盘。写任何文本,如“qwertyuio”,然后多次复制并粘贴此文本,直到达到限制。现在,从键盘应用程序按撤消将崩溃。我试图搜索但找不到任何解决方案。 例外: “由于未捕获的异常'NSRangeException'而终止应用程序,原因:'NSMutableRLEArray replaceObjectsInRange:withObject:length:: Out of bounds'”
代码,我正在使用:
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange,
replacementString string: String) -> Bool {
if textField.text?.count >= 40 && string != ""{
return false
}
return true
}
请提供解决方案。 谢谢
【问题讨论】:
标签: ios ipad uitextfield swift4.2 undo-redo