기간
2022/05/09 → 2022/05/15
전공
소프트웨어학부 컴퓨터과학전공
학번
1815364
이름
@김도이
// UIViewControlller 내부
let imagePickerViewController = UIImagePickerController()
@IBOutlet weak var catPhotoImageView: UIImageView!
// MARK: - Lifecycle
override func viewDidLoad() {
super.viewDidLoad()
imagePickerViewController.delegate = self
}
@IBAction func buttonGoAlbum(_ sender: Any) {
let alert = UIAlertController(title: "고양이 사진", message: "고양이 사진을 찍거나 선택해주세요.", preferredStyle: .actionSheet)
let library = UIAlertAction(title: "사진앨범", style: .default) { (action) in self.openLibrary()
}
let camera = UIAlertAction(title: "카메라", style: .default) { (action) in
self.openCamera()
}
let cancel = UIAlertAction(title: "취소", style: .cancel, handler: nil)
alert.addAction(library)
alert.addAction(camera)
alert.addAction(cancel)
present(alert, animated: true, completion: nil)
// self.present(imagePickerViewController, animated: true, completion: nil)
}
// MARK: - Helpers
func openLibrary(){
imagePickerViewController.sourceType = .photoLibrary
present(imagePickerViewController, animated: false, completion: nil)
}
func openCamera(){
imagePickerViewController.sourceType = .camera
present(imagePickerViewController, animated: false, completion: nil)
}
@IBAction func buttonGoImagePicker(_ sender: Any) {
let alert = UIAlertController(title: "고양이 사진", message: "고양이 사진을 찍거나 선택해주세요.", preferredStyle: .actionSheet)
let library = UIAlertAction(title: "사진앨범", style: .default) { (action) in self.openLibrary()
}
let camera = UIAlertAction(title: "카메라", style: .default) { (action) in
self.openCamera()
}
let cancel = UIAlertAction(title: "취소", style: .cancel, handler: nil)
alert.addAction(library)
alert.addAction(camera)
alert.addAction(cancel)
present(alert, animated: true, completion: nil)
// self.present(imagePickerViewController, animated: true, completion: nil)
}
// MARK: - Helpers
func openLibrary(){
imagePickerViewController.sourceType = .photoLibrary
present(imagePickerViewController, animated: false, completion: nil)
}
func openCamera(){
imagePickerViewController.sourceType = .camera
present(imagePickerViewController, animated: false, completion: nil)
}