1
的细胞时科插图不尊重我有一个包含两个部分一个UICollectionView。 我从故事板给出了left = 5和right = 5的部分插入。 我对两个部分的单元格使用相同的.xib。 我输入单元的大小在sizeForItemAtIndexPath
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
let itemWidth = self.collectionViewTrending.bounds.size.width - 10
if(indexPath.section == 0) {
return CGSizeMake(itemWidth , 200)
} else {
let product = self.products.objectAtIndex(indexPath.row) as! Product
let imageHeight = CGFloat(product.imageHeight)
return CGSizeMake(itemWidth, imageHeight * 0.81)
}
}
问题是这样的:
对于第0,小区的中心和部分插图被推崇。
对于第1部分,尊重左侧部分插图,但右侧没有,并且第1部分的所有单元格的右侧边缘均触及collectionView的右侧边缘。
为什么会发生这种情况,我该如何解决?