简体   繁体   English

调整集合视图单元格的屏幕尺寸

[英]Adjusting Collection View Cells for Screen Size

This is the code I am using to setup my collection view. 这是我用来设置收藏夹视图的代码。

- (void) setUpCollectionView {

UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];

[flowLayout setScrollDirection:UICollectionViewScrollDirectionHorizontal];

[flowLayout setMinimumInteritemSpacing:0.0f];

[flowLayout setMinimumLineSpacing:0.0f];

[flowLayout setItemSize:CGSizeMake(320, 566)];

[self.collectionView setPagingEnabled:YES];

[self.collectionView setCollectionViewLayout:flowLayout];

}

I am setting the item size of the flow layout to a set size. 我将流程布局的项目大小设置为设置的大小。 I want to know I can adjust this size for the current screen size the user is using. 我想知道我可以为用户使用的当前屏幕尺寸调整此尺寸。 Thanks. 谢谢。

如果您的集合视图设置有约束以使其适应屏幕大小,则将单元格大小设置为与集合视图相同。

[flowLayout setItemSize:CGSizeMake(self.collectionView.frame.size.width, self.collectionView.frame.size.height)];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM