@@ -17,11 +17,11 @@ enum PinMode {
1717
1818
1919final class PinEditViewController : UIViewController , UITextViewDelegate {
20- private var pinEntity : PinEntity
20+ private var pinEntity : PinEntity !
2121 var isAdded : ( ( PinEntity ) -> Void ) ? // 핀추가가 됐을때 호출되는 클로저 (홈에서만 사용)
2222 private var pickedImage : UIImage ?
2323
24- private var mapView : MKMapView
24+ private var mapView : MKMapView !
2525
2626 private let saveButton : UIButton = {
2727 let button = UIButton ( )
@@ -41,6 +41,9 @@ final class PinEditViewController: UIViewController, UITextViewDelegate {
4141 textview. textAlignment = . center
4242 textview. textColor = UIColor . black
4343 textview. font = UIFont . systemFont ( ofSize: 16 )
44+ textview. autocorrectionType = . no
45+ textview. autocapitalizationType = . none
46+ textview. spellCheckingType = . no
4447 return textview
4548 } ( )
4649
@@ -58,6 +61,9 @@ final class PinEditViewController: UIViewController, UITextViewDelegate {
5861 . value
5962 textfield. leftView = UIView ( frame: CGRect ( x: 0 , y: 0 , width: 16 , height: 0 ) )
6063 textfield. leftViewMode = . always
64+ textfield. autocorrectionType = . no
65+ textfield. autocapitalizationType = . none
66+ textfield. spellCheckingType = . no
6167 return textfield
6268 } ( )
6369
@@ -117,6 +123,16 @@ final class PinEditViewController: UIViewController, UITextViewDelegate {
117123 return toolbar
118124 } ( )
119125
126+ private func setImageToCameraButton( image: UIImage ? ) {
127+ guard let image else { return }
128+ self . pickedImage = image
129+ cameraButton. backgroundColor = . clear
130+ cameraButton. setImage ( nil , for: . normal)
131+ cameraButton. clipsToBounds = true
132+ cameraButton. layer. cornerRadius = 75
133+ cameraButton. setBackgroundImage ( image, for: . normal)
134+ }
135+
120136 // MARK: - viewDidLoad
121137 override func viewDidLoad( ) {
122138 super. viewDidLoad ( )
@@ -127,9 +143,10 @@ final class PinEditViewController: UIViewController, UITextViewDelegate {
127143 }
128144
129145 init ( pinMode: PinMode ) {
146+ super. init ( nibName: nil , bundle: nil )
147+
130148 switch pinMode {
131149 case let . create( latitude, longitude) :
132- print ( " \( latitude) , \( longitude) " )
133150 self . pinEntity = PinEntity (
134151 pin_id: UUID ( ) ,
135152 title: " " ,
@@ -142,13 +159,14 @@ final class PinEditViewController: UIViewController, UITextViewDelegate {
142159 )
143160
144161 case let . edit( PinEntity) :
145- print ( PinEntity)
146162 self . pinEntity = PinEntity
147- print ( " 편집 모드입니다 " )
148163 dateLabel. text = pinEntity. date. koreanDateString ( )
149164 titleTextField. text = pinEntity. title
150165 contentTextView. text = pinEntity. description
166+ self . setImageToCameraButton ( image: pinEntity. mediaPath)
151167 }
168+
169+
152170 let map = MKMapView ( )
153171 let lat = pinEntity. latitude
154172 let long = pinEntity. longitude
@@ -165,7 +183,6 @@ final class PinEditViewController: UIViewController, UITextViewDelegate {
165183
166184 mapView = map
167185
168- super. init ( nibName: nil , bundle: nil )
169186 }
170187
171188 required init ? ( coder: NSCoder ) {
@@ -198,8 +215,9 @@ final class PinEditViewController: UIViewController, UITextViewDelegate {
198215
199216 weatherImage. snp. makeConstraints {
200217 $0. top. equalTo ( mapView. snp. bottom) . offset ( 10 )
201- $0. leading. equalTo ( view. snp. centerX) . offset ( 100 )
202- $0. height. width. equalTo ( 30 )
218+ // $0.leading.equalTo(view.snp.centerX).offset(100)
219+ $0. trailing. equalToSuperview ( ) . inset ( 20 )
220+ $0. height. width. equalTo ( 35 )
203221 }
204222
205223 dateLabel. snp. makeConstraints {
@@ -255,7 +273,6 @@ final class PinEditViewController: UIViewController, UITextViewDelegate {
255273
256274 pinEntity. title = titleTextField. text ?? " "
257275 pinEntity. description = contentTextView. text ?? " "
258-
259276 pinEntity. mediaPath = pickedImage
260277
261278 isAdded ? ( pinEntity)
@@ -314,7 +331,7 @@ final class PinEditViewController: UIViewController, UITextViewDelegate {
314331
315332 //MARK: 키보드가 나타낼때 화면을 -300
316333 @objc func keyboardWillShow( notification: NSNotification ) {
317- view. frame. origin. y = - 300
334+ view. frame. origin. y = - 250
318335 }
319336
320337 //MARK: 키보드가 사라질 때 동작
@@ -344,19 +361,7 @@ extension PinEditViewController: UIImagePickerControllerDelegate, UINavigationCo
344361
345362 func imagePickerController( _ picker: UIImagePickerController , didFinishPickingMediaWithInfo info: [ UIImagePickerController . InfoKey : Any ] ) {
346363 if let selectedImage = info [ . editedImage] as? UIImage ?? info [ . originalImage] as? UIImage {
347- self . pickedImage = selectedImage
348- cameraButton. backgroundColor = . clear
349- cameraButton. setImage ( nil , for: . normal)
350- //
351- // // 이미지를 버튼 크기에 맞게 조정하여 설정
352- // let resizedImage = resizeImage(image: pickedImage, targetSize: CGSize(width: 150, height: 150))
353-
354- cameraButton. clipsToBounds = true
355- cameraButton. layer. cornerRadius = 75
356- cameraButton. setBackgroundImage ( pickedImage, for: . normal)
357-
358- // 선택한 이미지를 pinEntity에 저장 (나중에 경로로 변환하는 로직 추가 필요)
359- // pinEntity?.mediaPath = ...
364+ setImageToCameraButton ( image: selectedImage)
360365 }
361366 picker. dismiss ( animated: true , completion: nil )
362367 }
0 commit comments