2

My collectionView presents 20 items in landscape mode. In portrait mode, I only want 8 reusable items presented. How can I achieve this?

When does the collectionView call collectionView:numberOfItemsInSection: on the data source in order to update itself???

4

1 回答 1

8

更改方向时,您需要强制应用程序更改集合视图的布局:

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
                               duration:(NSTimeInterval)duration{

    [self.myCollectionView.collectionViewLayout invalidateLayout];
}

看到这个线程:UICollectionView 设置列数

祝你好运!

于 2013-07-17T21:21:48.680 回答