Conversation
|
지나가던.. 와비인데요.. 수빈님 아가🐶 .. 너무 귀여워요...😖 |
hwangJi-dev
left a comment
There was a problem hiding this comment.
수빈님,, 오늘도 많이 배워갑니다,, 최고최고최고오오오오오오!!!!!!!
|
|
||
| } | ||
|
|
||
| /// 코드베이스로 cell을 생성할때 필요한 초기화 함수 (인터페이스 빌더에서는 자동으로 초기화하기 때문에 init 필요 X) |
There was a problem hiding this comment.
놓칠 수 있는 부분이었는데, 다시한번 상기시키고 갑니다!!👍 쏘 친절...
There was a problem hiding this comment.
오... 주석덕에 cell을 코드로 작성할때 초기화가 필요하다는것을 알고 갑니다.. 수빈 슨배 짱
| func setupLayout() { | ||
| self.addSubview(categoryLabel) | ||
|
|
||
| categoryLabel.snp.makeConstraints { make in |
There was a problem hiding this comment.
다음에는 then을 같이 사용해봐도 좋을 것 같아요!! ㅎㅎ make in 을 쓰지 않고 $0. 으로 모든 프로퍼티에 접근 가능해서 snapkit과 함께 썼을 때 엄청 효율적이더라구요!! ㅎㅎ
There was a problem hiding this comment.
그동안 쪼금 무서워서 못쓰고 있었는데 이젠 정말루 then 선배릠을 마주할 때가 됐나봐여... 적용해보겠슴다!😊
|
|
||
| channelCollectionView.delegate = self | ||
| channelCollectionView.dataSource = self | ||
| categoriesCollectionView.delegate = self | ||
| categoriesCollectionView.dataSource = self | ||
| contentTableView.delegate = self | ||
| contentTableView.dataSource = self |
There was a problem hiding this comment.
좋아여! 사실 함수화를 하고 싶었는데 함수 이름을 어떤 식으로 할지 모르겠드라구여.. delegate랑 datasource로 나눠야할지.. collectionView랑 tableView로 나눌지.. 고민만 하다가 뒀네여...
혹시 지은님이라면 함수 이름 어떤 식으로 지으실 것 같나여.......?🧐
지은님 코드 쇽샥 완료🏅
| /// categoriesCollectionView에 들어갈 label의 크기를 categoryLabel이라는 임의의 label을 만들어서 계산 후 return | ||
| func setupLabelSize(index: Int) -> CGSize { | ||
| let categoryLabel = UILabel() | ||
| categoryLabel.text = categorieList[index] | ||
| categoryLabel.sizeToFit() | ||
|
|
||
| return categoryLabel.bounds.size | ||
| } | ||
| } |
There was a problem hiding this comment.
오 이코드 진짜 좋은 것 같아요! 저는 이렇게 return해서 사용할 생각은 못했었는데..! 최곱니당!!
| let size = setupLabelSize(index: indexPath.row) | ||
| return CGSize(width: size.width + 20, height: 30) |
| cell.contentTitleLabel.text = contentTitleList[indexPath.row] | ||
| cell.contentImageView.image = UIImage(named: "\(contentImageList[indexPath.row])") | ||
| cell.contentChannelImageView.image = UIImage(named: "wesoptProfile") | ||
| cell.contentMoreButton.setImage(UIImage(named: "moreMenuIcon"), for: .normal) |
There was a problem hiding this comment.
이렇게 cell에서 지정해줘야 할 값들이 많을 때 cell내에서 함수를 만들고, 그 함수를 불러와서 코드 한줄로 쓰는 방법도 있습니닷!! ㅎㅎ
noah0316
left a comment
There was a problem hiding this comment.
중간중간 강쥐보면서 힐링하며 봤습니다 수빈님..셤기간인데 너무 고생많으셨습니다!!
항상 친절한 주석을 써주시는 배려에 감동받고 갑니다 🥲
센스넘치는 코드 잘봤습니다 ㅎㅎ
|
|
||
| } | ||
|
|
||
| /// 코드베이스로 cell을 생성할때 필요한 초기화 함수 (인터페이스 빌더에서는 자동으로 초기화하기 때문에 init 필요 X) |
There was a problem hiding this comment.
놓칠 수 있는 부분이었는데, 다시한번 상기시키고 갑니다!!👍 쏘 친절...
| func configUI() { | ||
| contentTitleLabel.numberOfLines = 2 | ||
| contentTitleLabel.text = "4차 iOS 세미나: 라이브러리 사용과 함께 치킨 먹는 방법" | ||
| contentSubLabel.text = "WE SOPT · 조회수 100만회 · 3주전" |
There was a problem hiding this comment.
나중에 가서 필요할 때 변경해도 좋겠지만 혹시나 하여 ㅎㅎ 조회수 \(n)회, \(n)전 텍스트 빼고 다 변할 수 있는 친구들이니 따로 지정해주어도 좋을 것 같아요!!🤓
| "3주차 iOS: 떡볶이 사주세요 매운거로 사주세요", | ||
| "4주차 iOS: 오늘은 엽떡을 먹을까 응떡을 먹을까 신전을 먹을까?", | ||
| "5주차 iOS: 육회스터디 서치바 정리해서 올려야되는데", | ||
| "6주차 iOS: 자료구조 시험 망하는 법"] |
| switch collectionView { | ||
| case channelCollectionView: | ||
| guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: HomeChannelCVC.identifier, for: indexPath) as? HomeChannelCVC else {return UICollectionViewCell()} | ||
| cell.setData(channelName: channelNameList[indexPath.row], channelImage: channelImageList[indexPath.row]) | ||
| return cell | ||
|
|
||
| case categoriesCollectionView: | ||
| guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: HomeCategoryCVC.identifier, for: indexPath) as? HomeCategoryCVC else {return UICollectionViewCell()} | ||
| cell.categoryLabel.text = categorieList[indexPath.row] | ||
| return cell | ||
|
|
||
| default: | ||
| return UICollectionViewCell() | ||
| } | ||
| } |
There was a problem hiding this comment.
오 요렇게 cell 생성을 분기처리 해줄 수도 있군요!! 배워갑니다 ㅎㅎ✏️
There was a problem hiding this comment.
사실 if-else문으로 짰었는데 수빈슨배꺼 몰래 보고 호다닥 바꿔서 내서 칭찬받았다.. 수빈슨배 감사함다...
hellozo0
left a comment
There was a problem hiding this comment.
수빈슨배... snapkit쓰는거 넘 멋쪄..R....
조금 어려운 개념이나 내가 어떤 의도로 코드짰는지 주석으로 설명해주는거 넘 이해도 잘가고 해서 나도 담에 적용해보겠습니다!!
너무 수고했어욤~~!
|
|
||
| } | ||
|
|
||
| /// 코드베이스로 cell을 생성할때 필요한 초기화 함수 (인터페이스 빌더에서는 자동으로 초기화하기 때문에 init 필요 X) |
There was a problem hiding this comment.
오... 주석덕에 cell을 코드로 작성할때 초기화가 필요하다는것을 알고 갑니다.. 수빈 슨배 짱
| layer.cornerRadius = 14 | ||
| layer.borderWidth = 1 | ||
| layer.borderColor = .init(gray: 125/235, alpha: 0.5) | ||
| backgroundColor = .systemGray6 |
There was a problem hiding this comment.
제꺼에 달아줬던 부분이 이거군요..! 보고 적용해보겠습니당!
| contentImageView.contentMode = .scaleToFill | ||
| } | ||
|
|
||
| func setupLayout(){ |
There was a problem hiding this comment.
레이아웃 코드로 짜는 슨배.... 넘 멋잇습니다.... 아직은 눈으로 익혀가는 단계인지라 침만 흘릴께요
| switch collectionView { | ||
| case channelCollectionView: | ||
| guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: HomeChannelCVC.identifier, for: indexPath) as? HomeChannelCVC else {return UICollectionViewCell()} | ||
| cell.setData(channelName: channelNameList[indexPath.row], channelImage: channelImageList[indexPath.row]) | ||
| return cell | ||
|
|
||
| case categoriesCollectionView: | ||
| guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: HomeCategoryCVC.identifier, for: indexPath) as? HomeCategoryCVC else {return UICollectionViewCell()} | ||
| cell.categoryLabel.text = categorieList[indexPath.row] | ||
| return cell | ||
|
|
||
| default: | ||
| return UICollectionViewCell() | ||
| } | ||
| } |
There was a problem hiding this comment.
사실 if-else문으로 짰었는데 수빈슨배꺼 몰래 보고 호다닥 바꿔서 내서 칭찬받았다.. 수빈슨배 감사함다...
📌 관련 이슈
closed #7
📌 변경 사항 및 이유
3주차 과제 완료했슴다
📌 PR Point
스토리보드에 오브젝트를 올려서 IBOutlet 연결만 해주고, 오토레이아웃은 Snapkit을 활용해서 코드로 잡았습니다..
뷰는 전체적으로 collectionView 2개와 tableView 1개로 구성했습니다
저희 애기 귀엽죠... 봐주세여 자랑하는거에요...
📌 참고 사항
스토리보드와 코드를 같이 사용하려 하니까 약간 여기저기 정신이 없네요 효....🤯
뭔가 ui 설정하는 코드가 빠진 것 같은데..? 싶으면 아마 스토리보드에서 설정했을 수도 있습니다..
진짜 정신없이 해서 제가 어디서 뭘 했는지.... 조금 혼란스럽기도 하더라구여.....
뭘 한건지 이해가 안되거나 더 효율적으로 할 수 있는 부분이 있다면 코멘트... 부탁드림다😊
벌써 이미 3차 과제지만... 다음 과제부터는 좀 더 열심히 해보겠슴다....