gpt4 book ai didi

ios - UICollectionView-如何删除第一个单元格上方的间距?

转载 作者:可可西里 更新时间:2023-11-01 05:00:52 26 4
gpt4 key购买 nike

UICollectionView- 如何移除第一个单元格上方的间距?

我的顶部插图 = 0,行 = 10

enter image description here

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{


if (indexPath.row == 0) {
return CGSizeMake(collectionView.width, 44);
}
return CGSizeMake(300, 150);
}

- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
return UIEdgeInsetsMake(0, 10, 10, 10);
}

似乎与将第一个单元格设置为不同大小有关

如果我删除 sizeForItemAtIndexPath 中行 ==0 的检查并为所有单元格返回相同的内容,它与顶部齐平。

有什么想法吗?

最佳答案

解决方法就是在viewDidLoad里面写上

self.automaticallyAdjustsScrollViewInsets = NO;

关于ios - UICollectionView-如何删除第一个单元格上方的间距?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17875856/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com