Skip to content

Commit

Permalink
Fix bad layout for scope transition after orientation changed
Browse files Browse the repository at this point in the history
Fix bad layout for scope transition after orientation changed
  • Loading branch information
WenchaoD committed Aug 5, 2016
1 parent ee5e196 commit faca526
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 23 deletions.
2 changes: 1 addition & 1 deletion FSCalendar.podspec
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
40 changes: 19 additions & 21 deletions FSCalendar/FSCalendarAnimator.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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) {

Expand Down Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion FSCalendar/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.3.0.beta</string>
<string>2.3.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down

0 comments on commit faca526

Please sign in to comment.