Jtapplecalendar: Disable selection on future dates

Created on 15 May 2018  ·  7Comments  ·  Source: patchthecode/JTAppleCalendar

Version is 7.1.5

Hi, I have a calendar that can go through previous months but not to future months. The problem is for example today is May 15, 2018, right now I can click 16 and so on but I don't want those future dates to be selected.

All 7 comments

You get the selection of a date here, func calendar(_ calendar: JTAppleCalendarView, didSelectDate date: Date, cell: JTAppleCell?, cellState: CellState) {...} so you can set a condition accordingly. If it's a future date don't do such task else do.

or if you want to totally refuse the selection of future dates then implement something like

func calendar(_ calendar: JTAppleCalendarView, shouldSelectDate date: Date, cell: JTAppleCell?, cellState: CellState) -> Bool {
   return date < Date()
}

will close this issue, but let me know if youre still stuck.

I'm trying to this pass dates, and I used the function with the >= sign instead. But it won't let me select the current date?

Im not sure what you were trying to do.
But if you used

return date >= Date()

Then this logic will do what you coded it do. I can say anything if id do not know what date is.

Yah, I figured it out, printed out the system date and it was a different time than my Timezone, but worked just fine on my phone. Thx for quick rely

cool.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

leo150 picture leo150  ·  3Comments

oddpandadesign picture oddpandadesign  ·  5Comments

dimitris-c picture dimitris-c  ·  5Comments

PedroAnibarro1 picture PedroAnibarro1  ·  5Comments

Fatalution picture Fatalution  ·  3Comments