Chris лет назад: 5
Родитель
Сommit
8f5c9fe4b1

+ 1 - 2
RainbowPlanet/RainbowPlanet/Modules/MineModule/EditExpressAddress/View/EditExpressAddressTableViewCell.swift

@@ -120,7 +120,7 @@ class EditExpressAddressTableViewCell: UITableViewCell {
 
 extension EditExpressAddressTableViewCell: UITextViewDelegate {
     
-    func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {
+    func textViewDidChange(_ textView: UITextView) {
         if textView == editTextView {
             var fullStr = textView.text ?? ""
             if textView.text?.count ?? 0 > 180 {
@@ -132,7 +132,6 @@ extension EditExpressAddressTableViewCell: UITextViewDelegate {
                 editTextViewClosure(self.editTextView.text ?? "",(self.indexPath!))
             }
         }
-        return true
     }
     
 }

+ 1 - 2
RainbowPlanet/RainbowPlanet/Modules/OrderModule/OrderApplyRefund/View/OrderApplyRefundNoteInfoCell.swift

@@ -86,7 +86,7 @@ class OrderApplyRefundNoteInfoCell: UITableViewCell {
 
 extension OrderApplyRefundNoteInfoCell: UITextViewDelegate {
     
-    func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {
+    func textViewDidChange(_ textView: UITextView) {
         if textView == noteTextView {
             var fullStr = textView.text ?? ""
             if textView.text?.count ?? 0 > 180 {
@@ -98,7 +98,6 @@ extension OrderApplyRefundNoteInfoCell: UITextViewDelegate {
                 noteTextViewClosure(self.noteTextView.text ?? "")
             }
         }
-        return true
     }
     
 }

+ 1 - 2
RainbowPlanet/RainbowPlanet/Modules/OrderModule/OrderComment/View/OrderCommentTableViewCell.swift

@@ -265,7 +265,7 @@ extension OrderCommentTableViewCell: UICollectionViewDelegateFlowLayout,UICollec
 
 extension OrderCommentTableViewCell: UITextViewDelegate {
     
-    func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {
+    func textViewDidChange(_ textView: UITextView) {
         if textView == cmtTextView {
             var fullStr = textView.text ?? ""
             if textView.text?.count ?? 0 > 180 {
@@ -277,7 +277,6 @@ extension OrderCommentTableViewCell: UITextViewDelegate {
                 commentTextViewClosure(self.cmtTextView.text ?? "")
             }
         }
-        return true
     }
     
 }

+ 14 - 10
RainbowPlanet/RainbowPlanet/Modules/OrderModule/OrderPayOrder/View/ShoppingCartPayOrderFooter.swift

@@ -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 ?? "")
+        }
+    }
+    
 }