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
}
我已经体会到,如果我的UiCollectionview内容不超过屏幕边界,我无法滚动。是这样吗? 即使内容小于视图也可以滚动,但我不知道 – Starlord
不给定高度。顶部尾部约束可以解决您的问题。 –
所以你想说的是,UiCollectionView中的所有项目都是visibe,UiCollectionView不滚动?如果是的话,我相信这是应该发生的,因为没有什么可以滚动的。 –