【发布时间】:2016-09-19 07:00:49
【问题描述】:
我在我的应用中添加了UICollectionView。我已经给出了它的约束,例如集合视图的前导、尾随、顶部和一些固定高度。它显示所有项目。但我无法滚动它。请问是什么问题?
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 中的内容没有超出屏幕的边界,我就无法滚动。是这样吗?即使内容少于视图也可以滚动,但我不知道如何
-
不要给定高度。顶部底部前导尾随约束可能会解决您的问题。
-
所以你想说的是 UiCollectionView 中的所有项目都是可见的并且 UiCollectionView 没有滚动?如果是,那么我相信这应该发生,因为没有什么可滚动的。
-
你允许 userInteractionunabled 吗??
标签: ios iphone swift uicollectionview