2016-09-19 31 views
0

我在我的應用中添加了一個UICollectionView。我已經給出了它的約束,如領先,尾隨,頂部&收集視圖的一些固定高度。它顯示所有項目。但我無法滾動它。請說出是什麼問題?UIcollection視圖不滾動?

func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int { 

     return 1 
    } 
    func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 

     print("count is \(arr_collection.count)") 
     return arr_collection.count 
    } 
    func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { 

     let identifier="col_cell" 
     let cell:CollectionCell 
     cell=collectionView.dequeueReusableCellWithReuseIdentifier(identifier, forIndexPath: indexPath) as! CollectionCell 
     cell.img_cell.image=UIImage(named: arr_collection[indexPath.row]) 
     print("arr collection is \(arr_collection[indexPath.row])") 
     return cell 
    } 
+0

我已經體會到,如果我的UiCollectionview內容不超過屏幕邊界,我無法滾動。是這樣嗎? 即使內容小於視圖也可以滾動,但我不知道 – Starlord

+0

不給定高度。頂部尾部約束可以解決您的問題。 –

+0

所以你想說的是,UiCollectionView中的所有項目都是visibe,UiCollectionView不滾動?如果是的話,我相信這是應該發生的,因爲沒有什麼可以滾動的。 –

回答

1

CollectionViews Interface Builder中默認有「跳動」 enabled屬性,但必須指定它反彈在什麼方向。如果你不這樣做,並集合視圖的內容不超過該界限集合視圖,您將無法滾動。 enter image description here