2016-09-19 72 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