Search code examples
ioscalendartapku

iOS: Tapku calendar library - allow selecting multiple dates for current month


I am using Tapku library for calendar implementation. I could see that there is a way to add Markers for predefined start and end date but I want to allow users to select/unselect any number of dates from current month only, and want to generate event for each action.

Moreover, I have switched off the month navigation functionality by returning nil for Left and Right arrow to display only current month but not able to remove events for few previous and next months Date tiles that gets displayed on current month. I can still select previous month's day 31st to navigate to previous month or select 1st on next month to navigate to next month. Can I restrict the date selection to only current month please?

Thanks.


Solution

  • The touches are handled in TKCalendarMonthView.m in the following method:

    - (void) reactToTouch:(UITouch*)touch down:(BOOL)down
    

    look at the block at row 563:

    if(portion == 1)
    {
        selectedDay = day;
        selectedPortion = portion;
        [target performSelector:action withObject:[NSArray arrayWithObject:[NSNumber numberWithInt:day]]];
    }
    else if(down)
    {
        // this is the important part for you.
        // ignore it by adding a return here (or remove the following three lines)
        return;
        [target performSelector:action withObject:[NSArray arrayWithObjects:[NSNumber numberWithInt:day],[NSNumber numberWithInt:portion],nil]];
        selectedDay = day;
        selectedPortion = portion;
    }
    

    The selecting/deselecting perhaps doesn't work as you expect. It's not like setDateSelected and setDateDeselected.. instead there is a single UIImageView*, which represents the selected state. And that view is moved around to the current position. You can search for self.selectedImageView in the code to see, what is happening.

    So its not that easy to introduce multiple-date-selection. The architecture isn't built for that.