|
@@ -123,19 +123,23 @@ class ShoppingCartPayOrderFooter: BaseView {
|
|
|
|
|
|
extension ShoppingCartPayOrderFooter: UITextFieldDelegate {
|
|
|
|
|
|
- func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
|
|
|
+ func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
|
|
|
if textField == msgTextField {
|
|
|
- var fullStr = textField.text ?? ""
|
|
|
- if textField.text?.count ?? 0 > 80 {
|
|
|
- fullStr = String(fullStr.prefix(50)) as String
|
|
|
- textField.text = fullStr
|
|
|
- }
|
|
|
-
|
|
|
- if let buyerNoteBlock = self.buyerNoteBlock {
|
|
|
- buyerNoteBlock(self.msgTextField.text ?? "")
|
|
|
- }
|
|
|
+ textField.addTarget(self, action: #selector(textFieldDidChange(_:)), for: UIControl.Event.editingChanged)
|
|
|
}
|
|
|
return true
|
|
|
}
|
|
|
|
|
|
+ @objc func textFieldDidChange(_ textField: UITextField) {
|
|
|
+ var fullStr = textField.text ?? ""
|
|
|
+ if textField.text?.count ?? 0 > 80 {
|
|
|
+ fullStr = String(fullStr.prefix(50)) as String
|
|
|
+ textField.text = fullStr
|
|
|
+ }
|
|
|
+
|
|
|
+ if let buyerNoteBlock = self.buyerNoteBlock {
|
|
|
+ buyerNoteBlock(self.msgTextField.text ?? "")
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|