2
我有一個看起來像復位indexPath爲uicollectionview
第一小區將舉行一些文本集合視圖,並從第二小區起數據從數據管理
爲了處理這種填充我有這樣的代碼
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
if(indexPath.row==0){
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(customCellNibName, forIndexPath: indexPath)
let offer: TGOfferDataSource? = dataSource?.dataforIndexPath(indexPath) as? TGOfferDataSource
cell.setOfferData(offer!)
return cell
}
else if(indexPath.row != 0)
{
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(cellNibName, forIndexPath: indexPath)
let product: TGProductDataSource? = dataSource?.dataforIndexPath(indexPath) as? TGProductDataSource
cell.setProductData(product!)
return cell
}
}
該問題是從數據管理器的第一個產品隱藏在這個灰色單元格後面。
所以我想我將不得不增加索引路徑在elseif部分。 elseif部分中的indexPath也應該從0開始。 (Swift和單元格是xib)
任何想法該怎麼做?
感謝
看了一下this但如何在迅速
編輯 做到這一點如果我刪除,如果部分,它看起來像
你可以添加你的dataSource'dataforIndexPath'方法嗎?另外,爲什麼你的產品類叫做'TGProductDataSource'? –
@MichaëlAzevedodataforIndexPath只是返回indexPath.item處的數據值,非常明顯,而TG僅僅是我們的企業命名約定。感謝您的幫助,無論如何,下面的答案做到了訣竅 –
我試圖知道您是否需要一個indexpath作爲參數或者只是一個索引就足夠了,因爲它看起來像你沒有使用NSIndexPath的section屬性。 –