-
Notifications
You must be signed in to change notification settings - Fork 3
[Feat] #19 - 사진 가져오기 #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
사진선택 잘뵜어요 선배!! 액션시트도!
/// 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 알러트 컨트롤러 생성
- 액션 생성
- 애드액션
액션시트 만들기 잘 배워가요!
|
||
func openCamera() { | ||
/// 카메라 촬영 타입이 가능하다면 | ||
if UIImagePickerController.isSourceTypeAvailable(.camera) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오호... 카메라가 있는지 권한이 있는지 판단하는걸까요...?
/// UIImage 타입인 originalImage를 빼옴 | ||
if let image = info[UIImagePickerController.InfoKey.originalImage] as? UIImage { | ||
imageView.image = image | ||
imageView.contentMode = .scaleAspectFill /// 1:1 로 맞춰둔 imageView에 꽉 채우겠다. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
피커컨트롤러가 가진 정보에 접근할 수 있는 메서드...메모..
There was a problem hiding this comment.
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에 넣어준 겁니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
친절한 설명 감사합니다!! 👍 👍 👍
<string>카메라를 열어도 될까요?</string> | ||
<key>NSPhotoLibraryUsageDescription</key> | ||
<string>앨범을 열어봐도 될까요?</string> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
엌ㅋㅋㅋ 될까요??
extension ViewController: UIImagePickerControllerDelegate, UINavigationControllerDelegate { | ||
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
선택 완료뿐만 아니라 취소역시 분기처리가 필요한데요!
imagePickerControllerDidCancel(_:)
에서 취소를 눌렀을때 dismiss 를 추가하거나 하면 좋을거 같아요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오오,,,, 그러네요 ..! 싹 다 정리를 해둬야겠어요 진짜...
🌴 PR 요약
🌱 작업한 브랜치
🌱 작업한 내용
📌 참고 사항
앞에 날린 FloatingButton 풀리퀘를 아직 보지 않았다면? 나가주세요..🚪
아직 FloatingButton이 머지되지 않은 상황이라면? 나가주세요..🚪
꼭 그거 머지한 다음에 이 풀리퀘를 봐주시기 바랍니다.
그럼 file changed가 줄어들겁니다....
그리구 그 거 pod 설치하기 귀찮아서 그냥 스토리보드로 했습니다
📸 스크린샷
📮 관련 이슈