2017-02-22 40 views
0

我有一個2節的collectionView。每個部分將保存兩組圖像。我想給這兩個部分提供一個標題。除此之外,我還希望滾動方向是水平的。 滾動,我使用:給CollectionView Swift 3.0中的章節賦予標題?

if let layout = collectionFavourites.collectionViewLayout as? UICollectionViewFlowLayout { 
      layout.scrollDirection = .horizontal 

然而,這將simulataneously其中一個,當用戶滾動滾動兩個部分。

要polulate我的數據在這2個部分,我用下面的代碼:

switch indexPath.section 
     { 

     case 0: 
      gTableFavouriteImagesIndexArray.sort()) 
      let index = gTableFavouriteImagesIndexArray[indexPath.row] 
      let dictImage = gTableImageArray[index] 
      lblTitle.text = dictImage["Title"] as! String? 
      imgView.image = dictImage["image"] as! UIImage? 
     default: 
      gCollectionFavouriteImagesIndexArray.sort() 
      let index = gCollectionFavouriteImagesIndexArray[indexPath.row] 
      let dictImage = gCollectionImageArray[index] 
      lblTitle.text = dictImage["Title"] as! String? 
      imgView.image = dictImage["image"] as! UIImage? 
     } 

我要上側和下側的另一部分的圖像。但是,我把他們都看作同一部分。 請幫我解決這個問題。

回答

1

你可以通過一個帶有2節的tableView(每節一行)來實現。 然後在將保存兩組圖像的部分中創建一個collectionView。