のセルをレンダリングするときセクション挿入図は、私は二つのセクションを含む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のすべてのセルの右端がコレクションビューの右端に接触します。
なぜこのようなことが起こり、どうすれば解決できますか?