I was told by some folks at WWDC that UICollectionView would be ideal for creating an EPG (Electronic Program Guide) style view in iOS, like the image below. However, I can't find any samples that are even close to this... does anyone know to go about it?
-
You would need a custom layout. Here's my thoughts: you use decoration view to show channel/time. And you layout your grids(blocks of programs) in landscape for each channel. – Shane Hsu Nov 22 '12 at 09:23
6 Answers
In a lot of cases you'll be able to get it done by subclassing the UICollectionViewFlowLayout
class. But in this case, you gotta write your own layout. Because UICollectionViewFlowLayout
is for line-based layouts, where lines break at the end. But in this case that wouldn't work.
So a custom layout is the way to go. You might wanna check the WWDC sessions on custom layouts and Apple's documentation.

- 166
- 5

- 5,706
- 3
- 27
- 37
Here is an example for creating an EPG Grid in swift using UICollectionView and custom UICollectionViewLayout https://github.com/CoderXpert/EPGGrid....

- 14,377
- 4
- 45
- 54
I got the same question - I'm not sure but I think you (we) would have to subclass
UICollectionViewFlowLayout
In order to achieve this layout :P

- 31
- 1
- 2
-
1
-
WWDC 2012 Session 219 "Advanced Collection Views and Building Custom Layouts". They describe how to subclass UICollectionViewFlowLayout/UICollectionViewLayout – Tom Albrecht Oct 05 '12 at 14:26
Well It looks simple, You just need one section in CollectionView and Height of each item same. To make length dynamic for item you just need this api where you can calculate your space and return a proper size.
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
this is one of UICollectionViewDelegateFlowLayout Protocol method. make sure your horizontal scrolling is enable for collection view, you can set it from storyboard.

- 105
- 2
- 9
https://github.com/NOUSguide/NGVaryingGridView A GridView which allows to set individual Rects for the Cells. So you can define Cells with different Sizes, used for e.g. in Timetables, EPGs, etc.
https://github.com/inspace-io/INSElectronicProgramGuideLayout UICollectionViewLayout for displaying electronic program guide which will help you.

- 5,039
- 36
- 35