我有以下设置,位于两个标头之间的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)];
}问题是,当上述情况发生时,它会与底部标头重叠。似乎完全忽略了底部标头上的Autolayout约束。在从上面的UICollectionView设置为大约25像素的空间的那一刻
如何使其在加载内容和集合视图时对下面的视图进行动态调整,以满足约束?
谢谢
发布于 2016-02-05 13:08:21
[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];会解决你的问题。
https://stackoverflow.com/questions/35222063
复制相似问题