Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- ios
- RxSwift
- 잡초가득블로그
- conflicting access to memory
- 대머리깃허브
- memory safety
- iOS 버전 점유율
- Git Large File Storage
- Apple Certificate
- 로버트마틴형
- 메모리 접근 충돌
- in-out
- Large File Storage
- coordinateSpace
- Dependency Rule
- SWIFT
- iOS Target
- Automatically manage signing
- swiftdocs
- UICoordinateSpace
- Dispatch.main.sync
- App Signing
- 클린아키텍쳐
- rib
- Concurrent
- Ribs
- windowScene
- RIBs Tutorial
- Github file size
- RxCocoa
Archives
- Today
- Total
빙수왕의 개발일지
UICollectionView의 cellForItem이 nil이 나올 때 본문
문제 상황
UICollectionView의 특정 셀을 디폴트로 설정해놓고 어떤 효과를 주고 싶었음.. 그러나 cellForItem을 사용해서
collectionView.cellForItem(at: IndexPath(row: strongSelf.currentPage.rawValue, section: 0))
위 코드를 실행했는데 nil이 나왔음.
컬렉션 뷰가 있고 셀을 다 넣어줬는데 왜??????
이유
Apple Developer Documentation
developer.apple.com
여기 보면 "visible cell"을 가져온다고 되어있었다..
해결방안
먼저 offset을 세팅해서 해당 셀이 보이는 상태로 스크롤을 맞춰놓고 cell 호출했다.
- 주의: 여기서 setContentOffset animated: "true" 하면 또 안됨. animate 하느라 바로 세팅이 안되나봄??
let offset = CGPoint.init(x: CGFloat(self.currentPage.rawValue) * self.contentsViewWidth, y: 0)
self.collectionView.setContentOffset(offset, animated: false)
'개발 > iOS' 카테고리의 다른 글
`self`에 Backquote를 넣는 이유 (0) | 2020.11.29 |
---|---|
Convenience init을 강제하는 법 (0) | 2020.11.29 |
withIdentifier 하드코딩 말고 다른방법 (0) | 2020.10.11 |
Swift 3개 이상의 값 비교하기 (0) | 2020.10.11 |
Playground 기능 (0) | 2020.08.07 |