2

在我的應用程序中,我使用UICollectionView獲取產品的列表。要求是有條件地設置單元高度。我使用下面的代碼。Collectionview單元格之間的最大空間

- (CGSize)collectionView:(UICollectionView *)collectionView 
        layout:(UICollectionViewLayout*)collectionViewLayout 
    sizeForItemAtIndexPath:(NSIndexPath *)indexPath; 
{ 
     if (indexPath.row == 3 || indexPath.row == 6 || indexPath.row == 7 || indexPath.row == 10 || indexPath.row == 0) 
     { 
      return CGSizeMake((collectionView.frame.size.width/2)-4, 300.0); 
     } 

     return CGSizeMake((collectionView.frame.size.width/2)-4, 250.0); 
} 

通過,此代碼完全設置單元格的高度,但水平單元格未正確設置圖像。我想要刪除垂直單元格之間的額外空間。我爲單元格設置最小間距,線條從故事板邊緣起8個像素。

預先感謝您。 enter image description here

+0

http://www.raywenderlich.com/107439/uicollectionview-custom-layout-tutorial-pinterest –

+0

@VirajPadsala我需要Objective-C和沒有約束。 –

回答

1

最後,我通過精彩的圖書館Link解決了這個問題,並且很容易實現。

+0

嗨,@Pramod Tapaniya祝賀400+聲望 –

+0

@Vyas謝謝。 –

+0

任何時候都非常歡迎 –

相關問題