I have a UICollectionView containing two sections.
I have given section insets of left = 5 and right = 5 from storyboard.
I am using the same .xib for cells of both the sections.
I am inputting the size of the cells in 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)
}
}
The problem is this :
For Section 0, the cell is centered and section insets are respected.
For Section 1, the left section inset is respected but the right isn't and all the cells of section 1 have their right edges touching the right edge of collectionView.
Why is this happening and how can I resolve it?