UICollectionView 特殊横流-多节 [英] UICollectionView special horizontal flow - multiple sections
本文介绍了UICollectionView 特殊横流-多节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 UICollectionView,根据设备方向不同,它的使用方式也不同.该图像描述了我拥有什么以及我需要什么.
I have a UICollectionView there is used differently depending on device orientation. The image describe what I have and what I need.
是否可以使用默认流程布局获得我需要的水平滚动",还是我需要制作自定义流程布局(感谢指南)或多个集合视图?
Is it possible to get "Horizontal scrolling as I need it" with default flowlayout or do I need to make customflowlayout(Guide appreciated) or multiple collectionviews?
推荐答案
我使用 DateFlowLayout.奇怪的名字,但它可以工作,有一些配置.
I solved it using DateFlowLayout. Strange name but it works, with some configurations.
这是我给你的设置(我只用于水平方向):
This was my setup to you it(I only used it for the horizontal direction):
- (void)layoutForOrientation:(UIInterfaceOrientation)orientation {
bool isPortrait = UIInterfaceOrientationIsPortrait(orientation);
self.collectionView.frame = isPortrait ? CGRectMake(0, 0, 768, 180) : CGRectMake(0, 60, 246, 595);
self.collectionView.collectionViewLayout = isPortrait ? DateFlowLayout.new : UICollectionViewFlowLayout.new;
self.flowLayout = ((UICollectionViewFlowLayout *)self.collectionView.collectionViewLayout);
self.flowLayout.scrollDirection = isPortrait ? UICollectionViewScrollDirectionHorizontal : UICollectionViewScrollDirectionVertical;
self.flowLayout.headerReferenceSize = isPortrait ? CGSizeMake(5, 30) : CGSizeMake(246, 40); //width is margin to the left of the header - must be bigger than 0 to show headers correct.
self.flowLayout.minimumInteritemSpacing = isPortrait ? 10 : 0;
self.flowLayout.minimumLineSpacing = isPortrait ? 17 : 7;
self.flowLayout.sectionInset = isPortrait ? UIEdgeInsetsMake(27, 30, 25, 0) : UIEdgeInsetsMake(0, 14, 0, 0);
//self.flowLayout.itemSize = CGSizeMake(58, 85); //You might need this
self.collectionView.alwaysBounceVertical = isPortrait ? NO : YES;
}
这篇关于UICollectionView 特殊横流-多节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文