I am writing a calendar based on UICollectionView
. One month - one section. The picture shows a view for the iPhone.
Is it possible to display sections in two columns - two sections on one line (display for iPad)?
I am writing a calendar based on UICollectionView
. One month - one section. The picture shows a view for the iPhone.
Is it possible to display sections in two columns - two sections on one line (display for iPad)?
Yes, it can be done. You must specify scrollingDirection
: [myFlowLayout setScrollDirection:UICollectionViewScrollDirectionHorizontal];
There are two ways to arrange sections in 2 columns:
Use nested collections when the cell of the first collection contains the collection as a subview
. In this case, we get the following problems:
overloaded UI - lags will be noticeable when you first start
problems with viewForSupplementaryElementOfKind
for the nested collection, since all headers and footers will have the same indexPath
problems with cellForItemAtIndexPath
for the nested collection - the method will not be called a second time, if there is already a drawn cell with the same indexPath
, the cell will simply be copied without updating the data.
All these problems can be solved programmatically, but it will turn out very ugly and confusing code.
Source: https://ru.stackoverflow.com/questions/559415/
All Articles