From 64a3739678a54a2ef3e2d084be9727af5864d2de Mon Sep 17 00:00:00 2001 From: Yannick Gagnon Date: Tue, 21 Jan 2025 08:46:14 -0500 Subject: [PATCH] Add tracking of currently displayed week/month section --- FSCalendar/FSCalendar.h | 7 +++++++ FSCalendar/FSCalendar.m | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/FSCalendar/FSCalendar.h b/FSCalendar/FSCalendar.h index 4cb9a3b0..b48badd3 100644 --- a/FSCalendar/FSCalendar.h +++ b/FSCalendar/FSCalendar.h @@ -291,6 +291,13 @@ IB_DESIGNABLE */ @property (strong, nonatomic) NSDate *currentPage; +/** + * The current section of calendar + * + * @desc In week mode, current section represents the current visible week; In month mode, it means current visible month. + */ +@property (readonly, nonatomic) NSInteger currentSection; + /** * The locale of month and weekday symbols. Change it to display them in your own language. * diff --git a/FSCalendar/FSCalendar.m b/FSCalendar/FSCalendar.m index d9c2781a..b7a09ea3 100644 --- a/FSCalendar/FSCalendar.m +++ b/FSCalendar/FSCalendar.m @@ -459,6 +459,11 @@ - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSe - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { + // Workaround to find the number of days in a week or month for Accessibility + if (_currentSection != indexPath.section) { + _currentSection = indexPath.section; + } + FSCalendarMonthPosition monthPosition = [self.calculator monthPositionForIndexPath:indexPath]; switch (self.placeholderType) {