我正在尝试使用单元格创建CollectionView。然而,它似乎一直隐藏在第一个细胞的顶部。当然,我可以设置顶级插图,但是,还有其他方法可以做到,或者我做错了什么?
我已经创建了一个UICollectionViewController并设置了以下内容。
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath, object: PFObject!) -> PFCollectionViewCell? {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("ItemCell", forIndexPath: indexPath) as? BrowseCell
cell?.titleLabel.text = object["title"] as! NSString as String
// cell?.myImageView.file = (object["images"] as [PFFile]).first
cell?.clipsToBounds = true
return cell
}
override func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAtIndex section: Int) -> CGFloat {
return 10
}
override func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAtIndex section: Int) -> UIEdgeInsets {
return UIEdgeInsetsMake(0, 10, 0, 10)
}
override func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
return CGSizeMake(self.view.frame.width/2-15, 100)
}