Giter VIP home page Giter VIP logo

inselectronicprogramguidelayout's Introduction

Introduction

INSElectronicProgramGuideLayout was written by Michał Zaborowski for inspace.io

INSElectronicProgramGuideLayout

INSElectronicProgramGuideLayout is a UICollectionViewLayout subclass for displaying Electronic Program Guide.

Example

The example project create sample data for the next three days channel data, it use LoremIpsum framework to fill EPG data. To run, build and run the Example target in from INSElectronicProgramGuideLayout.xcworkspace within the Example directory.

Usage

CocoaPods

Add the following to your Podfile and run $ pod install.

pod 'INSElectronicProgramGuideLayout'

If you don't have CocoaPods installed, you can learn how to do so here.

Invalidating Layout

If you change the content of your INSElectronicProgramGuideLayout, make sure to call the invalidateLayoutCache method. This flushes the internal caches of your INSElectronicProgramGuideLayout, allowing the data to be repopulated correctly.

Collection View Elements

INSElectronicProgramGuideLayout has eleven different elements that you should register UICollectionReusableView and UICollectionViewCell classes for. They are:

  • EPG Cell (UICollectionViewCell) – Represents your events.
  • Channel Column Header (UICollectionReusableView) element kind of (INSEPGLayoutElementKindSectionHeader) – Contains the channel text, top aligned.
  • Hour Row Header (UICollectionReusableView) element kind of (INSEPGLayoutElementKindHourHeader) – Contains the hour text, center aligned.
  • Half Hour Row Header (UICollectionReusableView) element kind of (INSEPGLayoutElementKindHalfHourHeader) – Contains the half hour text, center aligned.
  • Channel Column Header Background (UICollectionReusableView) element kind of (INSEPGLayoutElementKindSectionHeaderBackground) – Background of the channel column header.
  • Hour Row Header Background (UICollectionReusableView) element kind of (INSEPGLayoutElementKindHourHeaderBackground) – Background of the hour row header.
  • Current Time Indicator (UICollectionReusableView) element kind of (INSEPGLayoutElementKindCurrentTimeIndicator) – Displayed over the hour row header, aligned at the current time.
  • Current Time Vertical Gridline (UICollectionReusableView) element kind of (INSEPGLayoutElementKindCurrentTimeIndicatorVerticalGridline) – Displayed under the cells, aligned to the current hour.
  • Vertical Hour Gridilne (UICollectionReusableView) element kind of (INSEPGLayoutElementKindVerticalGridline) – Displayed under the cells, aligns with its corresponding hour row header.
  • Vertical Half Hour Gridilne (UICollectionReusableView) element kind of (INSEPGLayoutElementKindHalfHourVerticalGridline) – Displayed under the cells, aligns with its corresponding half hour row header.
  • Horizontal Gridilne (UICollectionReusableView) element kind of (INSEPGLayoutElementKindHorizontalGridline) – Displayed under the cells, aligns with its corresponding channel column header.
  • Floating Overlay (UICollectionReusableView) element kind of (INSEPGLayoutElementKindFloatingItemOverlay) – Displayed over the cells, aligns with its content.

Interface and customization

@interface INSElectronicProgramGuideLayout : UICollectionViewLayout

/**
*  Vertical space between sections (channels)
*/
@property (nonatomic, assign) CGFloat sectionGap;

/**
*  Section size
*/
@property (nonatomic, assign) CGFloat sectionHeight;
@property (nonatomic, assign) CGFloat sectionHeaderWidth;

/**
*  Current time indicator and gridline size
*/
@property (nonatomic, assign) CGSize currentTimeIndicatorSize;
@property (nonatomic, assign) CGFloat currentTimeVerticalGridlineWidth;

/**
*  Gridlines size
*/
@property (nonatomic, assign) CGFloat horizontalGridlineHeight;
@property (nonatomic, assign) CGFloat verticalGridlineWidth;

/**
*  Hour width and hour header height
*/
@property (nonatomic, assign) CGFloat hourWidth;
@property (nonatomic, assign) CGFloat hourHeaderHeight;

/**
*  Default size to use for floating headers. If the delegate does not implement the collectionView:layout:sizeForFloatingItemOverlayAtIndexPath: method, the flow layout uses the value in this property to set the size of each floating header.
*/
@property (nonatomic, assign) CGSize floatingItemOverlaySize;

/**
* Horizontal space between floating header and section.
Default value is 10.0
*/
@property (nonatomic, assign) CGFloat floatingItemOffsetFromSection;

/**
* Distances between the border and the layout content view.
* Default value is UIEdgeInsetsMake(0, 0, 0, 0)
*/
@property (nonatomic, assign) UIEdgeInsets contentMargin;

/**
*  Margin between cells.
*  Default value is UIEdgeInsetsMake(0, 0, 0, 10)
*/
@property (nonatomic, assign) UIEdgeInsets cellMargin;

@property (nonatomic, assign) INSElectronicProgramGuideLayoutType headerLayoutType;

/**
*  Set to YES if you want to resize sticky background headers when UICollectionView bounces.
*/
@property (nonatomic, assign) BOOL shouldResizeStickyHeaders;

/**
*  Set to YES if you want to use floting overlay to each cell. If set to YES you have to register supplementaryViewOfKind INSEPGLayoutElementKindFloatingItemOverlay.
*/
@property (nonatomic, assign) BOOL shouldUseFloatingItemOverlay;

Can I call performBatchUpdates:completion: to make stuff animate?

Don't do this. It doesn't work properly, and is a "bag of hurt".

Requirements

INSElectronicProgramGuideLayout requires either iOS 7.x and above.

Special thanks

I'd love a thank you tweet if you find this useful.

Special thanks to Eric Horacek who was originally wrote MSCollectionViewCalendarLayout, and i took many stuff from him.

Storyboard

INSElectronicProgramGuideLayout supports storyboard.

ARC

INSElectronicProgramGuideLayout uses ARC.

Contact

inspace.io

Twitter

License

Copyright (c) 2014 inspace.io. All rights reserved.

It is open source and covered by a standard 2-clause BSD license. That means you have to mention inspace.io as the original author of this code and reproduce the LICENSE text inside your app.

You can purchase a Non-Attribution-License for 35 Euros for not having to include the LICENSE text.

We also accept sponsorship for specific enhancements which you might need. Please contact us via email for inquiries.

inselectronicprogramguidelayout's People

Contributors

changzw avatar jkereako avatar jonasfrerestapptic avatar kchatzigeorgiou avatar m1entus avatar manumax avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

inselectronicprogramguidelayout's Issues

Performance issue

Hi,

I'm having an issue with the time needed to layout the collection view.

I have approximatively 300 channels and I let the user scroll until next week (data is paginated), which means there's a lot of data. When I scroll until "tomorrow" page, I load more data from my web service, invalidate the layout, reloadData on the collectionView and eventually call layoutIfNeeded on my collectionView. Reloading data & layoutIfNeeded take up to 10seconds.

After checking the layout code, it seems like disabling the cache in startDateForIndexPath: and endDateForIndexPath:fixes the issue.

What do you think about it?

time indicator

Hello, its a great great work!!

The my question; in your example you provided the ISCurrentTimeIndicatorView class, but how to use it?

thanks for your work.

A few questions

Hi guys!

First of all I want to say that the work youэму done is awesome!
I have a few questions:

  1. Is there any easy way to make the Y axe with bigger steps - I mean for example now the step is 30 minutes, is there any way to make it 1 hour to make everything more compact in time frame?
  2. What is the best way to update data shown? For example delete everything and pull new data...or add new Channel or Programme to the channel...

Thank you!!!

crash

UICollectionView received layout attributes for a cell with an index path that does not exist

"Minimum" start/end time for collection view.

Hi,
regarding #2, I've found out a potential improvement but I don't know if it could be of any interest to the project.
On that pull request, delegate has been extended to let lib's clients to define a fixed start/end time instead of showing only the interval of time derived by the start/end time of each cell.
A possible improvement (that I'm already using) is to intend those fixed start/end time as "minimum" values. In this way, is it possible to define a minimum size for the collection view, but it is still possible to present cells that are outside the given range.
What do you think?

Drag & drop row functionality.

Firstly thank you for great job, its really awesome library.

I want to know that, there is any functionalities for drag & drop row in your library. if there then please help me.

Thank you in advance. :)

if loading Data very quickly it is crashing

Hi ,

When loading data quickly it crashed.

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCache setObject:forKey:cost:]: attempt to insert nil value

How can I use it with swift 3?

I have downloaded the program guide and wish to use it in my project.
I have dded it using pod and in my bridging have put:
#import "INSElectronicProgramGuideLayout/INSElectronicProgramGuideLayout.h"

I also copied the Electronic Program Guide Cene to my storyboard.
I have created a segue from a button to the cene.
I also created a class called EpgViewController as:

import UIKit

class EpgViewController: UICollectionViewController
{
}

Now, when I click the button to show the empty cene, I get this error:

2017-05-09 17:40:30.660719-0300 ipTv3[884:169392] -[ipTv3.EpgViewController currentTimeForCollectionView:layout:]: unrecognized selector sent to instance 0x167b7530
2017-05-09 17:40:30.663947-0300 ipTv3[884:169392] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ipTv3.EpgViewController currentTimeForCollectionView:layout:]: unrecognized selector sent to instance 0x167b7530'
*** First throw call stack:
(0x1d93bb3d 0x1cbc3067 0x1d940fd1 0x1d93f0c3 0x1d867d08 0x1d6a25f 0x1d663b9 0x1d63939 0x1d627bb 0x22bc57c3 0x22bc4db1 0x22bc47ab 0x22b678c3 0x207c4cb7 0x207b8d77 0x207b8c05 0x20747849 0x20765feb 0x20766b3f 0x1d8f7803 0x1d8f5a55 0x1d8f6017 0x1d8490ef 0x1d848f11 0x1eff3b41 0x22bcde83 0x170e94 0x1d0364eb)
libc++abi.dylib: terminating with uncaught exception of type NSException

Do you have any example on how to implement the INSElectronicProgramGuideLayout using swift?

Thank you very much for any help.

Issue with loading more items for sections

Hi Team,

We have integrated your sample INSElectronicProgramGuideLayout into our application.
First of all I want congratulate you guys for this excellent sample for EPG Guide and it also helped us in Many ways.
All of a sudden we are facing a issue which we need your help to sort it out.
Please find below details of steps for issue.

  1. We are loading the EPG for Current Day (12:00 AM to 11:30 PM) and scrolling it current live time.
  2. We have requirement like when the user scrolls the guide to right and when he reaches to end of the day we have load next day EPG and populate into the guide.
  3. when we fetch the next day data we are invalidating the cache and then reloading the data again as per your instructions.
  4. Now the issue is we are able to load the next 2 days of data from Current Day. But, when we try to load the third day data. it is not populating into the guide.

We have tried to sort it out our end but we couldn’t do it.

Please help us in this regard as we are struck as this is a major issue for us.

Cells are not selectable

The delegate method for - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath doesn't seem to get called when clicking on a cell

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.