From faca526609ac833ef4f1aa2af4d897f5e4888834 Mon Sep 17 00:00:00 2001 From: Wenchao Ding Date: Fri, 5 Aug 2016 14:26:43 +0800 Subject: [PATCH] Fix bad layout for scope transition after orientation changed Fix bad layout for scope transition after orientation changed --- FSCalendar.podspec | 2 +- FSCalendar/FSCalendarAnimator.m | 40 ++++++++++++++++----------------- FSCalendar/Info.plist | 2 +- 3 files changed, 21 insertions(+), 23 deletions(-) diff --git a/FSCalendar.podspec b/FSCalendar.podspec index 2f2e0067..4acf6001 100644 --- a/FSCalendar.podspec +++ b/FSCalendar.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "FSCalendar" - s.version = "2.3.0.beta" + s.version = "2.3.0" s.summary = "A superiorly awesome iOS7+ calendar control, compatible with both Objective-C and Swift2." s.homepage = "https://github.com/WenchaoD/FSCalendar" diff --git a/FSCalendar/FSCalendarAnimator.m b/FSCalendar/FSCalendarAnimator.m index 836233e7..fe070c3a 100644 --- a/FSCalendar/FSCalendarAnimator.m +++ b/FSCalendar/FSCalendarAnimator.m @@ -109,17 +109,8 @@ - (void)scopeTransitionDidBegin:(UIPanGestureRecognizer *)panGesture self.calendarScope = FSCalendarScopeMonth; self.calendarCurrentPage = self.pendingAttributes.targetPage; - self.calendar.contentView.clipsToBounds = YES; - self.calendar.contentView.fs_height = CGRectGetHeight(self.pendingAttributes.targetBounds)-self.calendar.scopeHandle.fs_height; - self.collectionViewLayout.scrollDirection = (UICollectionViewScrollDirection)self.calendar.scrollDirection; - self.calendar.header.scrollDirection = self.collectionViewLayout.scrollDirection; - self.calendar.needsAdjustingMonthPosition = YES; - self.calendar.needsAdjustingViewFrame = YES; - [self.calendar setNeedsLayout]; - [self.collectionView reloadData]; - [self.calendar.header reloadData]; - [self.calendar layoutIfNeeded]; + [self prelayoutForWeekToMonthTransition]; self.collectionView.fs_top = -self.pendingAttributes.focusedRowNumber*self.calendar.preferredRowHeight; @@ -262,18 +253,8 @@ - (void)performScopeTransitionFromScope:(FSCalendarScope)fromScope toScope:(FSCa case FSCalendarTransitionWeekToMonth: { self.calendarCurrentPage = attr.targetPage; - self.collectionViewLayout.scrollDirection = (UICollectionViewScrollDirection)self.calendar.scrollDirection; - self.calendar.header.scrollDirection = self.collectionViewLayout.scrollDirection; - self.calendar.needsAdjustingMonthPosition = YES; - self.calendar.needsAdjustingViewFrame = YES; - [self.calendar layoutSubviews]; - [self.collectionView reloadData]; - [self.collectionView layoutIfNeeded]; - [self.calendar.header reloadData]; - [self.calendar.header layoutIfNeeded]; - - self.calendar.contentView.clipsToBounds = YES; + [self prelayoutForWeekToMonthTransition]; if (animated) { @@ -738,6 +719,23 @@ - (void)performPathAnimationWithProgress:(CGFloat)progress } } + +- (void)prelayoutForWeekToMonthTransition +{ + self.calendar.contentView.clipsToBounds = YES; + self.calendar.contentView.fs_height = CGRectGetHeight(self.pendingAttributes.targetBounds)-self.calendar.scopeHandle.fs_height; + self.collectionViewLayout.scrollDirection = (UICollectionViewScrollDirection)self.calendar.scrollDirection; + self.calendar.header.scrollDirection = self.collectionViewLayout.scrollDirection; + self.calendar.needsAdjustingMonthPosition = YES; + self.calendar.needsAdjustingViewFrame = YES; + [self.calendar setNeedsLayout]; + [self.collectionView reloadData]; + [self.calendar.header reloadData]; + [self.calendar layoutIfNeeded]; + [self.calendar.collectionView.visibleCells setValue:@YES forKey:@"needsAdjustingViewFrame"]; + [self.calendar.collectionView.visibleCells makeObjectsPerformSelector:@selector(setNeedsLayout)]; +} + @end diff --git a/FSCalendar/Info.plist b/FSCalendar/Info.plist index 0b3346dd..344518fa 100644 --- a/FSCalendar/Info.plist +++ b/FSCalendar/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 2.3.0.beta + 2.3.0 CFBundleSignature ???? CFBundleVersion