꾸준히 안타치기

사진첩에서 사진 가져오기, datepicker 본문

iOS/storyboard & code

사진첩에서 사진 가져오기, datepicker

글자줍기 2021. 12. 21. 15:31
반응형

https://www.boostcourse.org/mo326/lecture/256094?isDesc=false 

 

iOS 앱 프로그래밍

부스트코스 무료 강의

www.boostcourse.org

import UIKit

//delegate 메소드 2개가 필요
class SecondViewController: UIViewController,UIImagePickerControllerDelegate, UINavigationControllerDelegate {
    
    @IBOutlet weak var nameLabel : UILabel!
    @IBOutlet weak var ageLabel : UILabel!
    
    // 이미지 피커
    lazy var imagePicker : UIImagePickerController = {
        
        let picker: UIImagePickerController = UIImagePickerController()
        picker.sourceType = .photoLibrary
        picker.delegate = self
        return picker
    }()
    
    @IBOutlet weak var imageView: UIImageView!
    
    @IBAction func touchUpSelectImageButton(_ sender: UIButton){
        self.present(self.imagePicker, animated: true, completion: nil)
    }
    
    func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
        self.dismiss(animated:true, completion: nil)
    }
    
    func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {

            if let originalImage:UIImage =  info[UIImagePickerController.InfoKey.originalImage] as? UIImage {
                self.imageView.image = originalImage
            }
            self.dismiss(animated: true, completion: nil)

        }
   

}

 

https://www.boostcourse.org/mo326/lecture/16885?isDesc=false 

 

iOS 앱 프로그래밍

부스트코스 무료 강의

www.boostcourse.org

데이트 피커

 

반응형

'iOS > storyboard & code' 카테고리의 다른 글

액션시트 / 얼럿  (0) 2021.12.27
사진첩에서 이미지 가져오기 / 삭제하기  (0) 2021.12.26
세그(Segue) / 화면전환  (0) 2021.12.23
TableVIew / custom  (0) 2021.12.21
테이블뷰 / DataSource와 Delegate  (0) 2021.12.21
Comments