Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom calendar view cell size. #49

Open
markst opened this issue Jan 13, 2015 · 2 comments
Open

Custom calendar view cell size. #49

markst opened this issue Jan 13, 2015 · 2 comments

Comments

@markst
Copy link

markst commented Jan 13, 2015

I'm subclassing PDTSimpleCalendarViewController so that I can use a custom cell size.
Which works fine:

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    CGFloat itemWidth = floorf(CGRectGetWidth(self.collectionView.bounds) / self.daysPerWeek);
    return CGSizeMake(itemWidth, 35.0);
}

However this causes issues when scrolling to date: scrollToDate:
Since the y origin in calculated:
origin.y -= (PDTSimpleCalendarFlowLayoutHeaderHeight + PDTSimpleCalendarFlowLayoutInsetTop + self.collectionView.contentInset.top);

@jmig
Copy link
Contributor

jmig commented Jan 13, 2015

What's happening?
Can you post a screenshot?

From what I see you only specify a fixed height. This shouldn't interfere with the scrollToDate method.

@markst
Copy link
Author

markst commented Jan 14, 2015

ah so the issue is because I'm using a smaller size calendar view (90 pt high) which means the entire height of the calendar month doesn't fit.

A resolution for this is in the method scrollToDate:
Rather than scrolling to the date month section, scrolling to the exact index path works:

UICollectionViewLayoutAttributes *sectionLayoutAttributes = [self.collectionView layoutAttributesForItemAtIndexPath:selectedDateIndexPath];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants