我试图调整UICollectionView的高度,将视图控制器加载时设置为0,然后在按下按钮时使用动画增加其大小。我尝试了一些不同的东西,但它的大小根本不变。这里的所有不同的东西,我试图把它的高度更改为0:调整大小UICollectionView高度
CGRect bounds = [self.collectionView bounds];
[self.collectionView setBounds:CGRectMake(bounds.origin.x,
bounds.origin.y,
bounds.size.width,
bounds.size.height - 100)];
....
CGRect frame = [self.collectionView frame];
[self.collectionView setFrame:CGRectMake(frame.origin.x,
frame.origin.y,
frame.size.width,
frame.size.height - 100)];
....
CGRect frame = self.collectionView.frame;
frame.size.height -= 100;
self.collectionView.frame = frame;
....
self.collectionView.clipsToBounds = YES;
self.collectionView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
是'self.collectionView'实际设置的东西?你在使用AutoLayout吗? – mattjgalloway
我将集合视图设置为出口。是AutoLayout已打开。 –
如果你使用AutoLayout,那么你将不得不改变约束而不是直接改变框架。您需要在集合视图上设置高度限制。 – mattjgalloway