From c2290afd371b1f39b39c3479ac9bf7097b48b81b Mon Sep 17 00:00:00 2001 From: taipaise Date: Sat, 7 Feb 2026 22:26:45 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=A0=9C=EB=B3=B4=20=EB=93=B1=EB=A1=9D?= =?UTF-8?q?=20=ED=99=94=EB=A9=B4=20QA=20=EB=8C=80=EC=9D=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ReportRegistration/ReportTextView.swift | 21 ++++++++++- .../ReportRegistrationViewController.swift | 37 ++++++++++++++++++- .../ReportRegistrationViewModel.swift | 3 ++ 3 files changed, 58 insertions(+), 3 deletions(-) diff --git a/Projects/Presentation/Sources/Report/View/Component/ReportRegistration/ReportTextView.swift b/Projects/Presentation/Sources/Report/View/Component/ReportRegistration/ReportTextView.swift index 8640e66..4424209 100644 --- a/Projects/Presentation/Sources/Report/View/Component/ReportRegistration/ReportTextView.swift +++ b/Projects/Presentation/Sources/Report/View/Component/ReportRegistration/ReportTextView.swift @@ -34,9 +34,14 @@ final class ReportTextView: UIView { private let textView = UITextView() private let chevronImage = UIImageView() private let button = UIButton() + private var maxLength: Int? weak var delegate: ReportTextViewDelegate? + override var isFirstResponder: Bool { + return textView.isFirstResponder + } - init(type: ReportTextViewType, placeholder: String?) { + init(type: ReportTextViewType, placeholder: String?, maxLength: Int? = nil) { + self.maxLength = maxLength super.init(frame: .zero) configureAttribute(type: type, placeholder: placeholder) configureLayout(type: type) @@ -158,6 +163,11 @@ extension ReportTextView: UITextViewDelegate { func textViewDidChange(_ textView: UITextView) { updatePlaceholderVisibility() + + if let maxLength = self.maxLength, (textView.text?.count ?? 0) > maxLength { + textView.text = String(textView.text?.prefix(maxLength) ?? "") + } + delegate?.reportTextViewDidChanged(self, text: textView.text) } @@ -165,4 +175,13 @@ extension ReportTextView: UITextViewDelegate { updatePlaceholderVisibility() delegate?.reportTextViewDidChanged(self, text: textView.text) } + + func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool { + guard let maxLength = self.maxLength else { return true } + + let currentString = (textView.text ?? "") as NSString + let newString = currentString.replacingCharacters(in: range, with: text) + + return newString.count <= maxLength + } } diff --git a/Projects/Presentation/Sources/Report/View/ReportRegistrationViewController.swift b/Projects/Presentation/Sources/Report/View/ReportRegistrationViewController.swift index f2b6641..6b2d0d2 100644 --- a/Projects/Presentation/Sources/Report/View/ReportRegistrationViewController.swift +++ b/Projects/Presentation/Sources/Report/View/ReportRegistrationViewController.swift @@ -63,7 +63,10 @@ final class ReportRegistrationViewController: BaseViewController 0 else { + let message = "더 이상 사진을 선택할 수 없습니다." + let alertController = UIAlertController(title: "알림", message: message, preferredStyle: .alert) + alertController.addAction(UIAlertAction(title: "확인", style: .default)) + self.present(alertController, animated: true) + return + } + let picker = PHPickerViewController(configuration: config) picker.delegate = self present(picker, animated: true) @@ -537,6 +552,24 @@ final class ReportRegistrationViewController: BaseViewController