Jtapplecalendar: Cell isn't passed to didDeselectDate

Created on 23 Feb 2017  路  5Comments  路  Source: patchthecode/JTAppleCalendar

I have a configureCell() function that I call from willDisplayCell... you can see it in that same example I sent you for the other issue.

When a cell is deselected, I call that same function for the deselected cell, which causes the selection view to disappear.

About a month ago this was working perfectly (and I tried it with an older commit and it worked fine). With the latest version, however, it doesn't work as expected:

2017-02-22 22_22_05

(If the gif animation doesn't work click on the image to open it by itself.)

You can try it on that same example app; if you select January 27th (it only happens with some dates, I don't know why), scroll to February and select a different date, when you go back to January the 27th should not be selected anymore, but it still is.

The problem is that the cell isn't being passed to didDeselectDate:

    func calendar(_ calendar: JTAppleCalendarView, didDeselectDate date: Date,
                  cell: JTAppleDayCellView?, cellState: CellState) {

        if let cell = cell as? CellView {
            // cell is nil, so this isn't called!
            configureCell(cell, date: date, cellState: cellState)
        }

    }

I don't know if this is intentional, but it didn't happen before. And if it is intentional I don't know how to make the selection view hidden again once a cell is deselected now.

Already Fixed on Master Branch bug

All 5 comments

ok checking it out now

Man.. your code was a little hard to read. So I cleaned it up.
I also fixed the bug.
checkout latest here -> https://github.com/patchthecode/JTOrientationTest

Sorry for the messy code, I just copied/pasted random stuff to make an example for the orientation problem. 馃槼
But how weird... now I'm comparing my version and yours and it seems like in my version willDisplayCell isn't called for some of the cells when you scroll to a different month. I don't know what could be causing that. But if you print the date right at the start of willDisplayCell you can see that for some dates it's just not called, and that's why some of the cells weren't deselected. willDisplayCell should be called for every cell, shouldn't it? Do you know what I've done in my code to prevent that?

Closing as issue is resolved on latest master branch

Thanks! :)

Was this page helpful?
0 / 5 - 0 ratings