【发布时间】:2020-12-11 23:03:42
【问题描述】:
我不断收到此警告:
2020-08-22 17:33:31.484454-0500 bob-app-ios[95799:7064579]
Failed to set (lineColor) user defined inspected property on
(projectName.UnderlinedTextField): [<projectName.UnderlinedTextField 0x7fbca5084e00>
setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key lineColor.
在模拟器中运行我的项目时,这是我的UnderlinedTextField 类:
import UIKit
class UnderlinedTextField: UITextField {
var isWriting = false
let bottomLine = CALayer()
func underlined() {
self.delegate = self
let width = CGFloat(1.0)
reloadUnderlinedTextField()
bottomLine.frame = CGRect(x: 0, y: self.frame.size.height - width, width: self.frame.size.width, height: self.frame.size.height)
bottomLine.borderWidth = width
self.layer.addSublayer(bottomLine)
self.layer.masksToBounds = true
}
func reloadUnderlinedTextField() {
bottomLine.borderColor = isWriting ? ColorManager.PrimaryColor?.cgColor : ColorManager.Gray500?.cgColor
}
}
extension UnderlinedTextField: UITextFieldDelegate {
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
let maxLength = 1
let currentString: NSString = (textField.text ?? "") as NSString
let newString: NSString =
currentString.replacingCharacters(in: range, with: string) as NSString
return newString.length <= maxLength
}
func textFieldDidBeginEditing(_ textField: UITextField) {
isWriting = true
reloadUnderlinedTextField()
}
func textFieldDidEndEditing(_ textField: UITextField) {
isWriting = false
reloadUnderlinedTextField()
}
}
我应该担心吗?我该如何解决?
我也收到此警告:
2020-08-22 17:33:32.683970-0500 projectName[95799:7064579] Can't find keyplane that supports type 4
for keyboard iPhone-PortraitChoco-NumberPad; using 25752_PortraitChoco_iPhone-Simple-Pad_Default
我的应用没有崩溃,但我觉得应该注意这些警告,因此,非常感谢任何帮助。
【问题讨论】:
标签: ios swift uitextfield uistoryboard