From 28a09164a6fdeced774eac74732afea45cca3ffb Mon Sep 17 00:00:00 2001 From: dingwenchao Date: Wed, 4 Nov 2015 17:28:37 +0800 Subject: [PATCH] initWithFrame:collectionViewLayout should also be intercepted 1. initWithFrame:collectionViewLayout should also be overriden 2. Reset stickyHeaders after orientation changing --- FSCalendar/FSCalendar.m | 2 +- FSCalendar/FSCalendarCollectionView.m | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/FSCalendar/FSCalendar.m b/FSCalendar/FSCalendar.m index d4b6ec4..0de3ef0 100644 --- a/FSCalendar/FSCalendar.m +++ b/FSCalendar/FSCalendar.m @@ -650,7 +650,7 @@ _needsAdjustingMonthPosition = YES; _needsAdjustingTextSize = YES; [_collectionViewLayout invalidateLayout]; // Necessary in Swift. Anyone can tell why? - + [_stickyHeaderMapTable.dictionaryRepresentation.allValues setValue:@YES forKey:@"needsAdjustingFrames"]; _preferedWeekdayHeight = FSCalendarAutomaticDimension; _preferedRowHeight = FSCalendarAutomaticDimension; _preferedHeaderHeight = FSCalendarAutomaticDimension; diff --git a/FSCalendar/FSCalendarCollectionView.m b/FSCalendar/FSCalendarCollectionView.m index c309a5a..7d79462 100644 --- a/FSCalendar/FSCalendarCollectionView.m +++ b/FSCalendar/FSCalendarCollectionView.m @@ -12,6 +12,16 @@ @synthesize scrollsToTop = _scrollsToTop, contentInset = _contentInset; +- (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout +{ + self = [super initWithFrame:frame collectionViewLayout:layout]; + if (self) { + self.scrollsToTop = NO; + self.contentInset = UIEdgeInsetsZero; + } + return self; +} + - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame];