UICollectionCell职位问题

时间:2017-03-22 13:05:46

标签: ios swift uicollectionview ios-autolayout

enter image description here CollectionView单元格未找到正确的位置。我正在使用以下代码来创建集合视图

 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。您可以看到单元格的最大距离,为什么会出现这个空间。以及如何删除它?

1 个答案:

答案 0 :(得分:1)

在viewDidLoad中尝试此操作:

IntegerProperty