[Swift] StatusBar 클릭시 UICollectionView Cell의 AutoLayout이 깨질 때
아이폰 맨 위 상태바를 클릭했을 때 Cell의 위치가 이상한 곳으로 가면서 깨지는 현상이 있었다..
그것도 맨 첫번째 cell만 그랬는데
이유는 width랑 height을 고정으로 지정해줬는데 estimatedItemSize랑 itemSize를 automaticSize로 해줘가지고 충돌나서 그런 것 같다.
나중에 까먹을까봐 대충 적어두기
어떻게 깨졌는지 이미지를 첨부하자면,,
기대값은 아래와 같은데
페이징 내리다가 상태바를 클릭하면 이렇게 UI 화면이 깨져서 나와버린다 ㅠㅠ
private let collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout().then {
$0.minimumLineSpacing = 16
$0.minimumInteritemSpacing = 16
$0.scrollDirection = .vertical
$0.estimatedItemSize = UICollectionViewFlowLayout.automaticSize 👉 삭제
$0.itemSize = UICollectionViewFlowLayout.automaticSize 👉 삭제
}).then {
$0.register(skeletonViewCell.self, forCellWithReuseIdentifier: "skeletonViewCell")
$0.register(collectionViewCell.self, forCellWithReuseIdentifier: "collectionViewCell")
$0.register(headerView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: "headerView")
$0.showsVerticalScrollIndicator = false
$0.backgroundColor = .clear
}
이런식으로 작성해줬었는데 삭제 해줬돠
Author And Source
이 문제에 관하여([Swift] StatusBar 클릭시 UICollectionView Cell의 AutoLayout이 깨질 때), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@boms2/Swift-StatusBar-클릭시-UICollectionView-Cell의-AutoLayout이-깨질-때저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)