UICollectionView with FlowLayout not scrolling when setting section insets

后端 未结 3 1711
萌比男神i
萌比男神i 2021-02-03 11:22

I am using a UICollectionView programmatically.

I\'ve set its frame as follows:

UICollectionView *collectionView = [[UICollectionView alloc] initWithFram         


        
3条回答
  •  南笙
    南笙 (楼主)
    2021-02-03 11:53

    Setting the height of the UICollectionView to 3000 will make your scrolling problem worse. If the UICollectionView is 3000 pixels tall then it will only ever need to scroll if it has more than 3000 pixels worth of content in it. You should set it to the height of the view it is contained in (same as the width).

    AFAIK the also should not set the contentSize directly, instead you need to override the - (CGSize)collectionViewContentSize method in a subclass of UICollectionViewLayout, but generally speaking you shouldn't need to change the content size for normal uses.

    I'm not totally clear on what your problem is - is it that when you add more than a screens worth of items you can't scroll?

提交回复
热议问题