diff --git a/Example-Objc/DIYCalendarCell.m b/Example-Objc/DIYCalendarCell.m index 9cc63e0e..1c8b6f60 100644 --- a/Example-Objc/DIYCalendarCell.m +++ b/Example-Objc/DIYCalendarCell.m @@ -62,6 +62,12 @@ - (void)layoutSubviews } } +- (void)configureAppearance +{ + [super configureAppearance]; + self.eventIndicator.hidden = self.placeholder; // Hide the event indicator for placeholder cells +} + - (void)setSelectionType:(SelectionType)selectionType { if (_selectionType != selectionType) { diff --git a/Example-Objc/DIYExampleViewController.m b/Example-Objc/DIYExampleViewController.m index b7ff0f53..8d394e52 100644 --- a/Example-Objc/DIYExampleViewController.m +++ b/Example-Objc/DIYExampleViewController.m @@ -189,8 +189,6 @@ - (void)configureCell:(FSCalendarCell *)cell forDate:(NSDate *)date atMonthPosit // Configure selection layer if (monthPosition == FSCalendarMonthPositionCurrent || self.calendar.scope == FSCalendarScopeWeek) { - diyCell.eventIndicator.hidden = NO; - SelectionType selectionType = SelectionTypeNone; if ([self.calendar.selectedDates containsObject:date]) { NSDate *previousDate = [self.gregorian dateByAddingUnit:NSCalendarUnitDay value:-1 toDate:date options:0]; @@ -223,7 +221,6 @@ - (void)configureCell:(FSCalendarCell *)cell forDate:(NSDate *)date atMonthPosit diyCell.circleImageView.hidden = YES; diyCell.selectionLayer.hidden = YES; - diyCell.eventIndicator.hidden = YES; // Hide default event indicator if ([self.calendar.selectedDates containsObject:date]) { diyCell.titleLabel.textColor = self.calendar.appearance.titlePlaceholderColor; // Prevent placeholders from changing text color } diff --git a/FSCalendar.podspec b/FSCalendar.podspec index 8945a66c..157db77d 100644 --- a/FSCalendar.podspec +++ b/FSCalendar.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "FSCalendar" - s.version = "2.7.0" + s.version = "2.7.1" s.summary = "A superiorly awesome iOS7+ calendar control, compatible with Objective-C and Swift." s.homepage = "https://github.com/WenchaoD/FSCalendar" diff --git a/FSCalendar/FSCalendar.m b/FSCalendar/FSCalendar.m index c2fdeef6..6c39475d 100644 --- a/FSCalendar/FSCalendar.m +++ b/FSCalendar/FSCalendar.m @@ -72,7 +72,6 @@ @interface FSCalendar () _collectionView.contentSize.height-_collectionView.fs_height) { @@ -719,8 +710,6 @@ - (void)setScrollDirection:(FSCalendarScrollDirection)scrollDirection switch (_scope) { case FSCalendarScopeMonth: { - _supressEvent = YES; - _collectionViewLayout.scrollDirection = (UICollectionViewScrollDirection)scrollDirection; _calendarHeaderView.scrollDirection = _collectionViewLayout.scrollDirection; if (self.hasValidateVisibleLayout) { @@ -729,7 +718,6 @@ - (void)setScrollDirection:(FSCalendarScrollDirection)scrollDirection } _needsAdjustingViewFrame = YES; [self setNeedsLayout]; - _supressEvent = NO; break; } case FSCalendarScopeWeek: { @@ -1151,7 +1139,7 @@ - (void)selectDate:(NSDate *)date scrollToDate:(BOOL)scrollToDate atMonthPositio NSDate *targetDate = [self.gregorian dateBySettingHour:0 minute:0 second:0 ofDate:date options:0]; NSIndexPath *targetIndexPath = [self.calculator indexPathForDate:targetDate]; - BOOL shouldSelect = !_supressEvent; + BOOL shouldSelect = YES; // 跨月份点击 if (monthPosition==FSCalendarMonthPositionPrevious||monthPosition==FSCalendarMonthPositionNext) { if (self.allowsMultipleSelection) { @@ -1226,7 +1214,6 @@ - (void)scrollToDate:(NSDate *)date animated:(BOOL)animated return; } animated &= _scrollEnabled; // No animation if _scrollEnabled == NO; - _supressEvent = !animated; date = [self.calculator safeDateForDate:date]; NSInteger scrollOffset = [self.calculator indexPathForDate:date atMonthPosition:FSCalendarMonthPositionCurrent].section; @@ -1259,7 +1246,6 @@ - (void)scrollToDate:(NSDate *)date animated:(BOOL)animated if (!animated) { self.calendarHeaderView.scrollOffset = scrollOffset; } - _supressEvent = NO; } - (void)scrollToPageForDate:(NSDate *)date animated:(BOOL)animated @@ -1284,13 +1270,11 @@ - (void)scrollToPageForDate:(NSDate *)date animated:(BOOL)animated break; } } - if (!_supressEvent && self.hasValidateVisibleLayout) { - _supressEvent = YES; + if (self.hasValidateVisibleLayout) { [self.delegateProxy calendarCurrentPageDidChange:self]; if (_placeholderType != FSCalendarPlaceholderTypeFillSixRows && self.transitionCoordinator.state == FSCalendarTransitionStateIdle) { [self.transitionCoordinator performBoundingRectTransitionFromMonth:lastPage toMonth:_currentPage duration:0.33]; } - _supressEvent = NO; } [self didChangeValueForKey:@"currentPage"]; } @@ -1385,8 +1369,8 @@ - (void)registerMainRunloopObserver void FSCalendarRunLoopCallback(CFRunLoopObserverRef observer, CFRunLoopActivity activity, void *info) { FSCalendar *calendar = (__bridge FSCalendar *)(info); - if ([calendar fs_boolVariableForKey:@"_needsConfigureAppearance"]) { - [calendar fs_setBoolVariable:NO forKey:@"_needsConfigureAppearance"]; + if (calendar.needsConfigureAppearance) { + calendar.needsConfigureAppearance = NO; [calendar.visibleCells makeObjectsPerformSelector:@selector(configureAppearance)]; [calendar.visibleStickyHeaders makeObjectsPerformSelector:@selector(configureAppearance)]; [calendar.calendarHeaderView configureAppearance]; @@ -1670,8 +1654,6 @@ - (void)invalidateViewFrames _preferredWeekdayHeight = FSCalendarAutomaticDimension; _preferredRowHeight = FSCalendarAutomaticDimension; - [self.collectionViewLayout invalidateLayout]; - [self.collectionViewLayout layoutAttributesForElementsInRect:CGRectZero]; [self.calendarHeaderView setNeedsAdjustingViewFrame:YES]; [self setNeedsLayout]; @@ -1691,7 +1673,6 @@ - (FSCalendarOrientation)currentCalendarOrientation - (void)adjustMonthPosition { [self requestBoundingDatesIfNecessary]; - _supressEvent = NO; NSDate *targetPage = self.pagingEnabled?self.currentPage:(self.currentPage?:self.selectedDate); [self scrollToPageForDate:targetPage animated:NO]; self.calendarHeaderView.needsAdjustingMonthPosition = YES; diff --git a/FSCalendar/FSCalendarCollectionViewLayout.m b/FSCalendar/FSCalendarCollectionViewLayout.m index 5b260c02..19ed3149 100644 --- a/FSCalendar/FSCalendarCollectionViewLayout.m +++ b/FSCalendar/FSCalendarCollectionViewLayout.m @@ -168,12 +168,7 @@ - (void)prepareLayout CGFloat *heights = malloc(rowSize); if (!self.calendar.floatingMode) { CGFloat contentHeight = self.collectionView.fs_height - self.sectionInsets.top - self.sectionInsets.bottom; - for (int i = 0; i < rowCount; i++) { - NSInteger currentCount = rowCount-i; - CGFloat actualHeight = FSCalendarRound(contentHeight/currentCount*2)*0.5; - contentHeight -= actualHeight; - heights[i] = actualHeight; - } + FSCalendarSliceCake(contentHeight, rowCount, heights); } else { for (int i = 0; i < rowCount; i++) { heights[i] = self.estimatedItemSize.height; @@ -181,6 +176,7 @@ - (void)prepareLayout } heights; }); + free(self.tops); self.tops = ({ NSInteger rowCount = self.calendar.transitionCoordinator.representingScope == FSCalendarScopeWeek ? 1 : 6; diff --git a/FSCalendar/FSCalendarHeaderView.m b/FSCalendar/FSCalendarHeaderView.m index 412b7a97..fe54ddff 100644 --- a/FSCalendar/FSCalendarHeaderView.m +++ b/FSCalendar/FSCalendarHeaderView.m @@ -173,7 +173,10 @@ - (void)setScrollOffset:(CGFloat)scrollOffset animated:(BOOL)animated - (void)scrollToOffset:(CGFloat)scrollOffset animated:(BOOL)animated { - [self layoutIfNeeded]; + if (CGSizeEqualToSize(self.collectionView.contentSize, CGSizeZero)) { + _needsAdjustingMonthPosition = YES; + return; + } if (self.scrollDirection == UICollectionViewScrollDirectionHorizontal) { CGFloat step = self.collectionView.fs_width*((self.scrollDirection==UICollectionViewScrollDirectionHorizontal)?0.5:1); [_collectionView setContentOffset:CGPointMake((scrollOffset+0.5)*step, 0) animated:animated]; diff --git a/FSCalendar/FSCalendarWeekdayView.m b/FSCalendar/FSCalendarWeekdayView.m index b13abd5e..5f15e104 100644 --- a/FSCalendar/FSCalendarWeekdayView.m +++ b/FSCalendar/FSCalendarWeekdayView.m @@ -79,12 +79,6 @@ - (void)layoutSubviews } -- (void)setCalendar:(FSCalendar *)calendar -{ - _calendar = calendar; - [self configureAppearance]; -} - - (void)configureAppearance { BOOL useVeryShortWeekdaySymbols = (self.calendar.appearance.caseOptions & (15<<4) ) == FSCalendarCaseOptionsWeekdayUsesSingleUpperCase; diff --git a/FSCalendar/Info.plist b/FSCalendar/Info.plist index 134b7a95..bf843754 100644 --- a/FSCalendar/Info.plist +++ b/FSCalendar/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 2.7.0 + 2.7.1 CFBundleSignature ???? CFBundleVersion