diff --git a/FSCalendar/FSCalendarCalculator.h b/FSCalendar/FSCalendarCalculator.h index 81a4311..469a9e2 100644 --- a/FSCalendar/FSCalendarCalculator.h +++ b/FSCalendar/FSCalendarCalculator.h @@ -34,6 +34,7 @@ typedef NS_ENUM(NSUInteger, FSCalendarMonthPosition); - (NSIndexPath *)indexPathForDate:(NSDate *)date atMonthPosition:(FSCalendarMonthPosition)position; - (NSIndexPath *)indexPathForDate:(NSDate *)date atMonthPosition:(FSCalendarMonthPosition)position scope:(FSCalendarScope)scope; +- (NSDate *)pageForSection:(NSInteger)section; - (NSDate *)weekForSection:(NSInteger)section; - (NSDate *)monthForSection:(NSInteger)section; - (NSDate *)monthHeadForSection:(NSInteger)section; diff --git a/FSCalendar/FSCalendarCalculator.m b/FSCalendar/FSCalendarCalculator.m index ffc0060..0c65e61 100644 --- a/FSCalendar/FSCalendarCalculator.m +++ b/FSCalendar/FSCalendarCalculator.m @@ -193,6 +193,18 @@ [self.rowNumbers removeAllObjects]; } +- (NSDate *)pageForSection:(NSInteger)section +{ + switch (self.calendar.scope) { + case FSCalendarScopeWeek: + return [self weekForSection:section]; + case FSCalendarScopeMonth: + return [self monthForSection:section]; + default: + break; + } +} + - (NSDate *)monthForSection:(NSInteger)section { NSNumber *key = @(section); @@ -282,9 +294,9 @@ - (FSCalendarMonthPosition)monthPositionForIndexPath:(NSIndexPath *)indexPath { - NSDate *month = [self monthForSection:indexPath.section]; + NSDate *page = [self pageForSection:indexPath.section]; NSDate *date = [self dateForIndexPath:indexPath]; - NSComparisonResult comparison = [self.gregorian compareDate:date toDate:month toUnitGranularity:NSCalendarUnitMonth]; + NSComparisonResult comparison = [self.gregorian compareDate:date toDate:page toUnitGranularity:NSCalendarUnitMonth]; switch (comparison) { case NSOrderedAscending: return FSCalendarMonthPositionPrevious; diff --git a/README.md b/README.md index b19f8e4..00e25e8 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ ![fscalendar-users](https://cloud.githubusercontent.com/assets/5186464/19956154/dd0f6bb4-a1c3-11e6-8fed-6aabbf999161.jpg) ## Fully DIV support -![1](https://cloud.githubusercontent.com/assets/5186464/20026517/bbba9b9a-a336-11e6-9bf6-a4f018c8489b.gif) +![1](https://cloud.githubusercontent.com/assets/5186464/20026796/9da4d2dc-a33c-11e6-8f21-54cd599cb939.gif) ## Working with AutoLayout and Orientation @@ -36,9 +36,6 @@ ## Hide placeholder dates ![fscalendar-showsplaceholder](https://cloud.githubusercontent.com/assets/5186464/13727902/21a90042-e940-11e5-9b9f-392f38cf007d.gif) -## Scope gesture -![scopegesture](https://cloud.githubusercontent.com/assets/5186464/16909556/276fa8a8-4d06-11e6-8092-587952edb395.gif) - > FSCalendar doesn't change frame or the constraint by itself, see [Adjusts frame dynamicly](#adjusts_frame_dynamicly)