0
UICollectionView를 포함한 몇 가지 요소가 포함 된 UIScrollView가 포함 된 UIViewController가 있습니다. UICollectionView는 고정 된 프레임에 N 개의 버튼을 표시하는 데 사용됩니다. UICollectionView 스크롤이 비활성화됩니다. 그래도 내 UIScrollView는 UICollectionView없이 스크롤하는 것처럼 부드럽게 스크롤하지 않습니다. 내 문제가 뭐지? 재사용 가능한 세포와 관련이 있습니까?UICcrollView의 UICollectionView는 고정되어 있습니다.
코드 :
가있는 ScrollView 및 collectionView의 프레임이 동일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 속성을 설정해야합니다. –