MBCalendarKit
MBCalendarKit copied to clipboard
Selecting last day of the week jumps to next week when firstDayOfWeek set to Monday
Steps to reproduce:
- Configure [CKCalendarView firstWeekDay] to be Monday (2)
- Run Demo app, change to Week view
- Select the last day of the current week (Sunday)
Observed: The week shown jumps forward by 1 week. Expected: The day should be selected, but the week shown should remain the same.
Thanks for the succinct bug report.
Do you think this has to do with the firstWeekday
fix you submitted last week? I think so, but I have to look at the code to see where the fix is.
I don't remember offhand, but there are probably some utility methods to determine what range of dates is being shown and then to determine if the selected day is in the visible range. Mostly, this has to do with the month view, because you can select dates in other months where weeks overlap two months.
Again, not sure, but that's where I'd start.
I don' think it had to do with my change, but I haven't confirmed that.
I think the issue resides in
-(NSDate *) [NSCalendar+Juncture firstDayOfTheWeekUsingReferenceDate:(NSDate *)date andStartDay:(NSInteger)day]
We've had some luck by making the following change, but I'm not sure this is the right answer for the generalized solution (for weeks starting on anything other than Monday).
- (NSDate *)firstDayOfTheWeekUsingReferenceDate:(NSDate *)date andStartDay:(NSInteger)day
{
// Make the calendar calculate Sunday correctly now that the week starts on Monday
NSInteger dayOfWeek = [self weekdayInDate:date];
if (dayOfWeek == 1) {
dayOfWeek = 8;
}
NSInteger weekday = dayOfWeek-day;
return [self dateBySubtractingDays:weekday fromDate:date];
}
Has this solution been working out for you?
Actually sorry to say I've switched to using another Calendar library (as I wanted something a little more decoupled).
That's disappointing, but I totally understand.
Which library are you using?
This is the project I'm currently using. https://github.com/jonathantribouharet/JTCalendar/
Cool. MBCalendarKit 5 moves towards that decoupling a bit with a lot of re-architecting. Most significantly, the calendar view no longer automatically installs the table view. Now, that behavior is only provided by CKCalendarViewController
.
Since I doubt there's any point to keeping it open, do you mind if we close this?