Skip to content

Conversation

yangsubinn
Copy link
Member

@yangsubinn yangsubinn commented Jan 8, 2022

🌴 PR 요약

🌱 작업한 브랜치

🌱 작업한 내용

  • actionSheet
  • 앨범에서 사진 가져오기
  • 촬영해서 사진 가져오기

📌 참고 사항

앞에 날린 FloatingButton 풀리퀘를 아직 보지 않았다면? 나가주세요..🚪
아직 FloatingButton이 머지되지 않은 상황이라면? 나가주세요..🚪
꼭 그거 머지한 다음에 이 풀리퀘를 봐주시기 바랍니다.
그럼 file changed가 줄어들겁니다....

머지했는데 왜 안줄어들죠? 당황스럽고 당황스럽습니다.

그리구 그 거 pod 설치하기 귀찮아서 그냥 스토리보드로 했습니다

📸 스크린샷

기능 스크린샷
사진 겟 ezgif com-gif-maker (26)

📮 관련 이슈

@yangsubinn yangsubinn self-assigned this Jan 8, 2022
Copy link
Member

@L-j-h-c L-j-h-c left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

사진선택 잘뵜어요 선배!! 액션시트도!

Comment on lines +31 to +48
/// alterController 생성
let alter = UIAlertController(title: "사진가져오기", message: "진짜로 사진을 가져오시겠어요?", preferredStyle: .actionSheet)

/// alter에 들어갈 액션 생성
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)

/// alter에 액션을 넣어줌
alter.addAction(library)
alter.addAction(camera)
alter.addAction(cancel)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 알러트 컨트롤러 생성
  2. 액션 생성
  3. 애드액션

액션시트 만들기 잘 배워가요!


func openCamera() {
/// 카메라 촬영 타입이 가능하다면
if UIImagePickerController.isSourceTypeAvailable(.camera) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오호... 카메라가 있는지 권한이 있는지 판단하는걸까요...?

Comment on lines +77 to +80
/// UIImage 타입인 originalImage를 빼옴
if let image = info[UIImagePickerController.InfoKey.originalImage] as? UIImage {
imageView.image = image
imageView.contentMode = .scaleAspectFill /// 1:1 로 맞춰둔 imageView에 꽉 채우겠다.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

피커컨트롤러가 가진 정보에 접근할 수 있는 메서드...메모..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

추가로 설명하자면
저 info라는 친구가 배열로 넘어오는데, 그 배열 중 UIImage 타입인 originalImage 친구만 뽑아서 image라는 새로 선언한 변수에 넣어주고,,
imageView에 넣어준 겁니다!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

친절한 설명 감사합니다!! 👍 👍 👍

@yangsubinn yangsubinn merged commit 8973327 into TeamSparker:develop Jan 9, 2022
Comment on lines +6 to +8
<string>카메라를 열어도 될까요?</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>앨범을 열어봐도 될까요?</string>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

엌ㅋㅋㅋ 될까요??

Comment on lines +72 to +73
extension ViewController: UIImagePickerControllerDelegate, UINavigationControllerDelegate {
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

선택 완료뿐만 아니라 취소역시 분기처리가 필요한데요!
imagePickerControllerDidCancel(_:) 에서 취소를 눌렀을때 dismiss 를 추가하거나 하면 좋을거 같아요!

참고: https://developer.apple.com/documentation/uikit/uiimagepickercontrollerdelegate/1619133-imagepickercontrollerdidcancel

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오오,,,, 그러네요 ..! 싹 다 정리를 해둬야겠어요 진짜...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feat] 사진 가져오기

3 participants