7
내가 내 응용 프로그램UICollectionView 동적 셀 높이 (대표자 : 레이아웃)
에 Pinterest 레이아웃을 달성하기 위해 노력하고있어 나는 그것을 달성하고 셀 높이를 설정하려면 다음 대리자 메서드를 사용하여 동적으로
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let boundingRect = CGRect(x: 0, y: 0, width: self.view.frame.size.width/2 - 20, height: CGFloat(MAXFLOAT))
let data = articles[indexPath.row]
let rect = AVMakeRect(aspectRatio: (data.coverImage?.size)!, insideRect: boundingRect)
return CGSize(width: rect.width, height: rect.height + 120) // Added 120 for a description I will add later
}
그러나
회색 배경 셀의 배경, 당신은 일을 볼 수 있습니다 나는 다음과 같은 결과를 얻었다 각 셀에는 (높이 예상대로) 자체 높이가 있지만 제거 방법을 모르는 여분의 공백이 있습니다.
어떻게 해결할 수 있습니까?
아무도 시도하지 않았습니까? 왜 대답이 없습니까? – adev