所以它們也同樣吸引我試圖使用collectionViewLayout sizeForItemAtIndexPath
同時在collectionView
只顯示一個項目和水平滾動,我已經試過這樣:collectionViewLayout sizeForItemAtIndexPath - > CGSize奇怪的行爲
- (void)viewDidLoad {
[super viewDidLoad];
flowLayout = [[UICollectionViewFlowLayout alloc]init];
flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
flowLayout.minimumInteritemSpacing = 0.0;
flowLayout.minimumLineSpacing = 0.0;
_obj_CollectionView.pagingEnabled = YES;
_obj_CollectionView.collectionViewLayout = flowLayout;
self.obj_CollectionView.delegate = self;
self.obj_CollectionView.dataSource = self;
_obj_CollectionView.backgroundColor = [UIColor redColor];
}
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
return CGSizeMake(collectionView.frame.size.width, collectionView.frame.size.height);
}
這裏的CollectionView截圖:
這裏紫色是我的手機和紅色是我的collectionView
,但我想在整個紫色。
所以請指導我。我很困惑。 :)
可以嘗試打印您的收藏視圖幀sizeForItemAtIndexPath並在viewDidAppear比較? – abarbier
我試過它的兩個框架都是一樣的 –
好吧,你可以打印collectionview的headerview和footerview大小 – abarbier