|
@@ -83,14 +83,7 @@ class EditExpressAddressTableViewCell: UITableViewCell {
|
|
|
editTextView.isScrollEnabled = false
|
|
|
editTextView.textContainer.lineFragmentPadding = 0
|
|
|
editTextView.textContainerInset = .zero
|
|
|
- editTextView.rx.text.orEmpty.changed.subscribe(onNext: {
|
|
|
- [weak self] (text) in
|
|
|
- self?.editTextView.text = String(text.prefix(150)) as String
|
|
|
- if let editTextViewClosure = self?.editTextViewClosure {
|
|
|
- editTextViewClosure(self?.editTextView.text ?? "",(self?.indexPath!)!)
|
|
|
- }
|
|
|
-
|
|
|
- }).disposed(by: disposeBag)
|
|
|
+ editTextView.delegate = self
|
|
|
return editTextView
|
|
|
}()
|
|
|
|
|
@@ -124,3 +117,22 @@ class EditExpressAddressTableViewCell: UITableViewCell {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+extension EditExpressAddressTableViewCell: UITextViewDelegate {
|
|
|
+
|
|
|
+ func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {
|
|
|
+ if textView == editTextView {
|
|
|
+ var fullStr = textView.text ?? ""
|
|
|
+ if textView.text?.count ?? 0 > 180 {
|
|
|
+ fullStr = String(fullStr.prefix(150)) as String
|
|
|
+ textView.text = fullStr
|
|
|
+ }
|
|
|
+
|
|
|
+ if let editTextViewClosure = self.editTextViewClosure {
|
|
|
+ editTextViewClosure(self.editTextView.text ?? "",(self.indexPath!))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true
|
|
|
+ }
|
|
|
+
|
|
|
+}
|