gpt4 book ai didi

ios - UICollectionCell 位置问题

转载 作者:行者123 更新时间:2023-11-28 15:46:29 26 4
gpt4 key购买 nike

enter image description here CollectionView 单元格未到达正确位置。我正在使用以下代码创建 Collection View

 let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout()
layout.sectionInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
layout.scrollDirection = UICollectionViewScrollDirection.Horizontal
viewListCollection = UICollectionView(frame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height), collectionViewLayout: layout)
layout.headerReferenceSize = CGSizeZero
layout.footerReferenceSize = CGSizeZero

viewListCollection.dataSource = self
viewListCollection.delegate = self
viewListCollection.backgroundColor = UIColor.whiteColor()
viewListCollection.tag = 9999
viewListCollection.registerNib(UINib(nibName: "SelectedContactCell", bundle: nil), forCellWithReuseIdentifier: "SelectedContactCell")
viewListCollection.scrollEnabled = true
viewListCollection.collectionViewLayout = layout
self.addSubview(viewListCollection)

蓝色是 CollectionView 的,黄色是 CollectionViewCell 的。您可以看到单元格的顶部距离,为什么会出现这个空间。以及如何删除它?

最佳答案

在您的 viewDidLoad 中试试这个:

self.automaticallyAdjustsScrollViewInsets = false

关于ios - UICollectionCell 位置问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42952505/

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