Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Differenciate between arrow click and date selection #97

Open
sumeshsreenivas opened this issue Oct 28, 2015 · 1 comment
Open

Differenciate between arrow click and date selection #97

sumeshsreenivas opened this issue Oct 28, 2015 · 1 comment

Comments

@sumeshsreenivas
Copy link

How to check whether the user clicked on the arrow or on the date cell?

@MosheBerman
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants