-
Notifications
You must be signed in to change notification settings - Fork 1
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
커스텀 앨범 생성 #27
커스텀 앨범 생성 #27
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.
고생하셨습니다 !!!
자잘한 코멘트 및 질문은 아래에 남겨뒀습니다 !
// MARK: - Initialize | ||
required init?(coder: NSCoder) { | ||
super.init(coder: coder) | ||
} |
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.
P2
required init
따로 구현해주신 이유가 있나요 ??
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.
지워야하는 코드인데 깜빡했습니다 .ᐟ.ᐟ 바로 수정하겠습니다 .ᐟ.ᐟ
|
||
final class CustomAlbumCollectionViewCell: UICollectionViewCell { | ||
// MARK: - Properties | ||
static let id = "CustomAlbumCollectionViewCell" |
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.
P2
id
라고 줄여쓰지말고, identifier
라고 적는 건 어떤가요 ?
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.
저는 "다 좋습니다~"
|
||
final class CustomAlbumCollectionViewCell: UICollectionViewCell { | ||
// MARK: - Properties | ||
static let id = "CustomAlbumCollectionViewCell" |
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.
P1
아래 Extension으로 처리하는 건 어떤까요 ?
휴먼 에러를 방지할 수 있을 것 같습니다
extension UICollectionViewCell {
static var identifier: String {
String(describing: self)
}
}
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.
P1 아래 Extension으로 처리하는 건 어떤까요 ? 휴먼 에러를 방지할 수 있을 것 같습니다
extension UICollectionViewCell { static var identifier: String { String(describing: self) } }
오 좋네요!
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { | ||
guard let imageAsset else { return 1 } | ||
return imageAsset.count + 1 | ||
} | ||
|
||
func collectionView( | ||
_ collectionView: UICollectionView, | ||
cellForItemAt indexPath: IndexPath | ||
) -> UICollectionViewCell { |
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.
P3
Delegate와 DataSource 메소드 선언 부를 모두 80~83처럼 인덴트를 가지는 건 어떨까요 ?
} | ||
|
||
// MARK: - UICollectionViewDelegate, UICollectionViewDataSource | ||
extension CustomAlbumViewController: UICollectionViewDelegate, UICollectionViewDataSource { |
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.
P3
extension UICollectionViewDelegate, UICollectionViewDataSource
을 한 번에 하지말고
각각 나누고 관련된 메소드 끼리 묶는 건 어떨까요 ?
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.
수정했습니다 !
MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/CustomAlbumViewController.swift
Show resolved
Hide resolved
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.
고생 많으셨습니다! 👍 👍 👍 👍 👍 👍 👍
|
||
final class CustomAlbumCollectionViewCell: UICollectionViewCell { | ||
// MARK: - Properties | ||
static let id = "CustomAlbumCollectionViewCell" |
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.
저는 "다 좋습니다~"
|
||
final class CustomAlbumCollectionViewCell: UICollectionViewCell { | ||
// MARK: - Properties | ||
static let id = "CustomAlbumCollectionViewCell" |
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.
P1 아래 Extension으로 처리하는 건 어떤까요 ? 휴먼 에러를 방지할 수 있을 것 같습니다
extension UICollectionViewCell { static var identifier: String { String(describing: self) } }
오 좋네요!
MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/CustomAlbumViewController.swift
Show resolved
Hide resolved
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.
고생하셨습니다 ~~ 늦어서 죄송해유🐯
navigationController?.pushViewController(imagePicker, animated: true) | ||
} else { | ||
// TODO: - 카메라 접근 권한 Alert | ||
print("카메라에 접근할 수 없습니다.") |
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.
P3
테스트 후 print는 지워줘도 좋을 것 같습니다!
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.
수정했습니다 .ᐟ.ᐟ
- Cell의 identifier 수정 - UICollectionViewDelegate와 UICollectionViewDataSource 프로토콜 extension 분리
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.
고생하셨습니다 〰️
#️⃣ 연관된 이슈
📝 작업 내용
📸 스크린샷
📒 리뷰 노트
CustomAlbum을 사용하기 위해서는 해당 VC을 부르기 전 아래 코드와 같이 앨범과 카메라에 대한 접근 권한을 확인한 후 접근해야합니다.
⚽️ 트러블 슈팅
1. 권한 설정
info.plist에서 이미지 및 카메라 권한 Description을 설정해주지 않은 상태로 사용자의 앨범이나 카메라에 접근하려고 하면 위와 같은 에러가 발생한다.
Target
→Info
→Privacy - Photo Library Usage Description
,Privacy - Camera Usage Description
두 key를 생성하고 경고 문구를 작성해줘야한다.
이때, 권한에 대한 설명을 충분히 해주지 않으면 앱 배포를 할 때 리젝을 당할 수 있으니 자세히 설명해주는 것이 좋다 ^0^
2. CollectionView의 Cell 밖으로 Image가 벗어나는 이슈
커스텀 앨범은 굉장히 간단한 기본 Grid 형태의 CollectionView이고 각각의 cell은
ImageView
하나만을 가지고 있는 구조였다.PHAsset
을 사용하여 image를 사용자의 앨범에서 가져오고 그 이미지를 cell에 넣어주기만 하면 되는 간단한 작업이었는데, 아래 사진과 같이 image가 Cell을 벗어나는 이슈가 발생했다.이상한 점은 뷰의 hierachy를 찍어보면 또 잘 나온다는 점이었다....
cell 혹은 cell 내부의 imageView 크기가 잘못되었나 하고 LLDB를 활용하여 디버깅을 해봐도 아래와 같이 정사각형 형태로 잘 나왔다.
열심히 claud를 사용해보았지만 다 이상한 이야기만 해주고...
결국 cell의 imageView에서
clipsToBounds
프로퍼티를true
로 해줌으로써 해결할 수 있었다 .ᐟ.ᐟ