diff --git a/NADA-iOS-forRelease.xcodeproj/project.pbxproj b/NADA-iOS-forRelease.xcodeproj/project.pbxproj index e18a67ff..bec52429 100644 --- a/NADA-iOS-forRelease.xcodeproj/project.pbxproj +++ b/NADA-iOS-forRelease.xcodeproj/project.pbxproj @@ -1182,7 +1182,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = 4QG3GC35LA; + DEVELOPMENT_TEAM = T3VFJ764ZC; INFOPLIST_FILE = "NADA-iOS-forRelease/Info.plist"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -1202,7 +1202,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = 4QG3GC35LA; + DEVELOPMENT_TEAM = T3VFJ764ZC; INFOPLIST_FILE = "NADA-iOS-forRelease/Info.plist"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", diff --git a/NADA-iOS-forRelease/Sources/Cells/CreationCard/BackCardCreationCollectionViewCell.swift b/NADA-iOS-forRelease/Sources/Cells/CreationCard/BackCardCreationCollectionViewCell.swift index f9fb3b2f..3d16a5e7 100644 --- a/NADA-iOS-forRelease/Sources/Cells/CreationCard/BackCardCreationCollectionViewCell.swift +++ b/NADA-iOS-forRelease/Sources/Cells/CreationCard/BackCardCreationCollectionViewCell.swift @@ -12,9 +12,12 @@ class BackCardCreationCollectionViewCell: UICollectionViewCell { // MARK: - Properties static let identifier = "BackCardCreationCollectionViewCell" + private let flavorList = ["민초", "반민초", "소주", "맥주", "부먹", "찍먹", "양념", "후라이드"] + private let maxLength: Int = 20 private var textFieldList = [UITextField]() private var requiredCollectionViewList = [UICollectionView]() + public weak var backCardCreationDelegate: BackCardCreationDelegate? // MARK: - @IBOutlet Properties @@ -42,6 +45,7 @@ class BackCardCreationCollectionViewCell: UICollectionViewCell { setUI() registerCell() textFieldDelegate() + setNotification() } } @@ -109,9 +113,48 @@ extension BackCardCreationCollectionViewCell { private func textFieldDelegate() { _ = textFieldList.map { $0.delegate = self } } + private func setNotification() { + NotificationCenter.default.addObserver(self, selector: #selector(textFieldDidChange(_:)), name: UITextField.textDidChangeNotification, object: nil) + } static func nib() -> UINib { return UINib(nibName: Const.Xib.backCardCreationCollectionViewCell, bundle: Bundle(for: BackCardCreationCollectionViewCell.self)) } + + // MARK: - @objc Methods + + @objc + private func textFieldDidChange(_ notification: NSNotification) { + if let textField = notification.object as? UITextField { + switch textField { + case firstTMITextField: + if let text = firstTMITextField.text { + if text.count > maxLength { + let maxIndex = text.index(text.startIndex, offsetBy: maxLength) + let newString = String(text[text.startIndex.. maxLength { + let maxIndex = text.index(text.startIndex, offsetBy: maxLength) + let newString = String(text[text.startIndex.. maxLength { + let maxIndex = text.index(text.startIndex, offsetBy: maxLength) + let newString = String(text[text.startIndex.. Void)? public var presentingMBTIBottomVCClosure: (() -> Void)? @@ -160,6 +161,7 @@ extension FrontCardCreationCollectionViewCell { NotificationCenter.default.addObserver(self, selector: #selector(setBirthTextField(notification:)), name: .frontCardBirth, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(setMBTITextField(notification:)), name: .frontCardMBTI, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(setCardBackgroundImage(notifiation:)), name: .sendNewImage, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(textFieldDidChange(_:)), name: UITextField.textDidChangeNotification, object: nil) } /// front card 가 편집되었는지. 필수 항목이 다 입력되었는지 체크. @@ -209,13 +211,44 @@ extension FrontCardCreationCollectionViewCell { cardBackgroundImage = notifiation.object as? UIImage backgroundSettingCollectionView.reloadData() } + @objc + private func textFieldDidChange(_ notification: Notification) { + if let textField = notification.object as? UITextField { + switch textField { + case cardTitleTextField: + if let text = cardTitleTextField.text { + if text.count > maxLength { + let maxIndex = text.index(text.startIndex, offsetBy: maxLength) + let newString = String(text[text.startIndex.. maxLength { + let maxIndex = text.index(text.startIndex, offsetBy: maxLength) + let newString = String(text[text.startIndex.. maxLength { + let maxIndex = text.index(text.startIndex, offsetBy: maxLength) + let newString = String(text[text.startIndex..