1️⃣ tableView.estimatedRowHeight 설정이 누락됨
UITableView.automaticDimension을 사용하려면 estimatedRowHeight를 설정
해결 방법: viewDidLoad()에서 estimatedRowHeight 값을 추가
override func viewDidLoad() {
super.viewDidLoad()
detailTableView.delegate = self
detailTableView.dataSource = self
// ✅ 높이 자동 조절 설정
detailTableView.estimatedRowHeight = 100 // 임의의 예상 높이 설정
detailTableView.rowHeight = UITableView.automaticDimension
}
2️⃣ UILabel의 translatesAutoresizingMaskIntoConstraints = false 누락 여부
이미 코드에는 설정되어 있지만, 혹시 contentView의 크기가 자동으로 조절되지 않는 경우를 대비하여 오토레이아웃을 명확히 보장해야 합니다.
해결 방법:
- contentView.bottomAnchor가 overviewLabel.bottomAnchor와 정확히 연결되었는지 확인
- compressionResistancePriority와 huggingPriority를 추가하여 UILabel이 자연스럽게 크기를 변경하도록 설정
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
contentView.backgroundColor = .black
// ✅ 셀 자체의 크기를 유동적으로 변경
contentView.translatesAutoresizingMaskIntoConstraints = false
// ✅ UILabel이 자동 크기 조절을 우선하도록 설정
overviewLabel.setContentHuggingPriority(.defaultHigh, for: .vertical)
overviewLabel.setContentCompressionResistancePriority(.defaultHigh, for: .vertical)
configureConstraints()
}
'Project > MovieClip' 카테고리의 다른 글
상세페이지에서 video, poster 데이터를 UICollectionView로 구현 (0) | 2025.02.11 |
---|---|
헷갈리기 쉬운 주요 출연진 정보를 받아오는 로직 (0) | 2025.02.10 |
TMDB에서 특정 조건의 video 정보 받아오기 (0) | 2025.02.10 |
✅ UIScrollView 안에 UITableView를 넣는 것이 올바른가? (상세페이지 구현) (0) | 2025.02.09 |
셀 재사용으로 인한 이전 데이터 표시되는 문제 (0) | 2025.02.08 |