0
我有一个UIViewController,其中包含UIScrollView,它包含一些元素,包括UICollectionView。 UICollectionView用于在固定帧中显示N个按钮。 UICollectionView滚动被禁用。尽管如此,我的UIScrollView不像UICollectionView那样滚动。我的问题是什么?它与可重复使用的单元格有关吗?UIScrollView UICollectionView冻结
代码:
func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
return 1
}
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 9
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("tagsCell", forIndexPath: indexPath) as! TagsCollectionViewCell
cell.backgroundColor = UIColor.clearColor()
cell.tagsButton.setTitle("Test", forState: .Normal)
cell.tagsButton.sizeToFit()
return cell
}
func collectionView(collectionView: UICollectionView!, layout collectionViewLayout: UICollectionViewLayout!,
sizeForItemAtIndexPath indexPath: NSIndexPath!) -> CGSize
{
let element = "Test" as NSString
let stringSize = element.sizeWithAttributes([NSFontAttributeName: UIFont.systemFontOfSize(17.0)])
return CGSize(width: stringSize.width + 25, height: 29)
}
滚动视图的高度大约是1000,而集合视图是150,宽度是一样的 – JuicyFruit
那么它不会产生问题。你能发布整个代码吗?以上只适用于collectionView。 –
你有没有设置scrollView contentSize的属性。 –