[英]How to adjust Autolayout positions of resizing UICollectionView?
我有以下設置,其中位於兩個標頭之間的UICollectionView
調整大小以適合其所有單元格。 它基本上是表格格式的2x2布局。
現在,一旦數據加載完畢,我將使用以下內容來調整UICollectionView
大小。
- (void)loadContent {
[self.collectionViewAboutProperty reloadData];
[self.labelAddress setText:stringAddress];
float totRows = [self.dictAboutProperty count];
float cHeight = ceil(totRows/2.0);
float collectionHeight = (cHeight * 20) + (cHeight * 5);
[self.collectionViewAboutProperty setFrame:CGRectMake(self.collectionViewAboutProperty.frame.origin.x, self.collectionViewAboutProperty.frame.origin.y, self.collectionViewAboutProperty.frame.size.width, collectionHeight)];
}
問題是,發生上述情況時,它與底部標頭重疊。 幾乎好像完全忽略了底部標題上的“自動布局”約束。 一分鍾,我將其設置為上述UICollectionView
的大約25像素的空間
我如何才能做到這一點,以便在加載內容並動態調整集合視圖的大小時,下面的視圖會自動更新以滿足約束條件?
謝謝
[self.labelAddress setText:stringAddress];
float totRows = [self.dictAboutProperty count];
float cHeight = ceil(totRows/2.0);
float collectionHeight = (cHeight * 20) + (cHeight * 5);
[self.collectionViewAboutProperty setFrame:CGRectMake(self.collectionViewAboutProperty.frame.origin.x, self.collectionViewAboutProperty.frame.origin.y, self.collectionViewAboutProperty.frame.size.width, collectionHeight)];
[self.collectionViewAboutProperty reloadData];
將解決您的問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.