📌 트러블 슈팅
⚠️ 의도한 대로 스크롤 뷰가 움직이지 않는 문제
- 수평으로 움직여야하는 스크롤뷰가 움직이지 않았다.
🗂️ 이전 코드
contentView.snp.makeConstraints {
$0.top.bottom.leading.trailing.equalToSuperview()
$0.height.equalTo(scrollView.frameLayoutGuide.snp.height)
}
contentView를 scrollView랑 똑같이 잡은 뒤에 높이만 frameLayoutGuide랑 같게 해주었다.
scrollView.snp.makeConstraints {
$0.top.leading.trailing.equalToSuperview()
$0.height.equalTo(60)
}
scrollView의 경우 높이를 정해주었기 때문에 bottom의 레이아웃을 잡지 않았었다.
💡 레이아웃 적절하게 잡아주기
func configure() {
(... 코드 생략)
scrollView.snp.makeConstraints {
$0.top.leading.trailing.bottom.equalToSuperview()
$0.height.equalTo(60)
}
contentView.snp.makeConstraints {
$0.leading.trailing.equalTo(scrollView.contentLayoutGuide)
$0.bottom.top.equalTo(scrollView.frameLayoutGuide)
}
}
scrollView의 bottom까지 레이아웃을 잡아줌. (height를 잡았어도 bottom까지 잡아주어야 함)
contentView에서 늘어날 수 있는 부분은 scrollView.contentLayoutGuide 같도록 해주었다.
- 늘어날 수 없는 부분은
scrollView.frameLayoutGuide와 같게 해주었다.