Differenciate between arrow click and date selection
sumeshsreenivas opened this issue · 1 comments
How to check whether the user clicked on the arrow or on the date cell?
I don't know if there's a good way to do this now, but here's my suggestion:
Add a property to your view controller called previousDate
and set it every time calendarView: willSelectDate:
is called. Inside of calendarView: didSelectDate:
you can calculate the distance between the new date and the old date in days.
Then check the distance between the two dates.
If it's greater than a week, then it's probably a month press. If the distance is a week, it's probably the arrow in the week view. If it's a day, and the mode is day view, then it could be either the arrow or the tap on a cell, but it probably doesn't matter.
@property (strong) NSDate *previousDate;
- (void)calendarView:(CKCalendarView *)calendarView willSelectDate:(NSDate *)date
{
self.previousDate = self.date;
}
- (void)calendarView:(CKCalendarView *)calendarView didSelectDate:(NSDate *)date
{
// Calculate distance between the two dates.
// There are some NSCalendar category methods in MBCalendarKit to help with this.
}
Hope this helps.