UICollectionView: How to define a UICollectionViewLayout that supports horizontally and vertically scrolling?

前端 未结 4 1726
梦毁少年i
梦毁少年i 2020-12-07 16:26

At the moment I\'m trying to create an UICollectionView, that should display a simple excel-like-spreadsheet, with rows and colu

4条回答
  •  悲&欢浪女
    2020-12-07 16:31

    Answer that doesn't require dissecting a 3 sample projects

    In your UICollectionViewLayout subclass:

    1. Implement -(CGSize)[collectionViewContentSize] and return a size larger in height and width than the UICollectionView's size. (Accessible via: self.collectionView.frame.size)
    2. Calculate layout for your UICollectionViewCells within the content size rather than the frame size.

    Note: Make sure scrolling is enabled in the UICollectionView. (It's on by default.)

提交回复
热议问题