Changing cell selection results in random cell deselection
(Required) Version Number: 8.0.3
Description
(multiple-selection) When cells are selected in my calendar sometimes the visual representation of the selection seems to not appear for some cells and it seems to be completely random. I don't exactly know why is this happening and have been struggling with this issue for quite a bit.
Such as in the photo below, not all desired dates are selected.
I have an array of dates that I want to select which I am comparing to "cellState.date".

Expected Behavior
All desired cells are selected.
paste me your 2 functions
- CellForItemAtIndexPath
- WillDisplayCell
func calendar(_ calendar: JTACMonthView, cellForItemAt date: Date, cellState: CellState, indexPath: IndexPath) -> JTACDayCell {
var cell = calendar.dequeueReusableJTAppleCell(withReuseIdentifier: "CalendarCell", for: indexPath) as! repeatsCalendarCell
cell = sharedFunctionToConfigureCell(cell: cell, cellState: cellState, date: date)
self.calendar(calendar, willDisplay: cell, forItemAt: date, cellState: cellState, indexPath: indexPath)
return cell
}
The "startDays" variable consists of the dates that I want to be selected.
func calendar(_ calendar: JTACMonthView, willDisplay cell: JTACDayCell, forItemAt date: Date, cellState: CellState, indexPath: IndexPath) {
var repeatsCell = cell as! repeatsCalendarCell
repeatsCell = sharedFunctionToConfigureCell(cell: repeatsCell, cellState: cellState, date: date)
}
func sharedFunctionToConfigureCell(cell: repeatsCalendarCell, cellState: CellState, date: Date) -> repeatsCalendarCell {
cell.dateLabel.text = cellState.text
if cellState.dateBelongsTo == .thisMonth {
cell.isHidden = false
} else {
cell.isHidden = true
}
var cellConfigured: Bool = false
for date in startDays {
if Calendar.current.isDate(calendar.startOfDay(for: cellState.date), inSameDayAs: calendar.startOfDay(for: date)) == true {
cell.isSelected = true
cellConfigured = true
}
}
if cellConfigured == false {
cell.isSelected = false
}
formatter.dateFormat = "MMM d, yyyy"
let cellDate = formatter.string(from: cellState.date)
let today = formatter.string(from: currentDate)
if cellDate == today {
cell.dateLabel.textColor = #colorLiteral(red: 0.5803921569, green: 0.1294117647, blue: 0.5764705882, alpha: 1)
} else {
cell.dateLabel.textColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
}
handleCellConfiguration(cell: cell, cellState: cellState)
return cell
}
Hey, our app is due to release soon, but this error has been holding our development back. I was responsible for the calendar, and I do not want to switch to another on because I really like this one, so I just wanted to remind you if it would be okej for you to have a look into the functions and identify the error.
It is something with your code... take my word for this one. you can switch to another lib - and if you shell have another problem? what you going to do? switch to another lib? I think the code here is not sufficient to find the bug - can you upload sample code to debug? do you use the selection function correctly?
calendarView.selectDates(from: range.startDate, to: range.endDate, triggerSelectionDelegate: false, keepSelectionIfMultiSelectionAllowed: true
just few few weeks ago I have used this lib in my project - at last stage I found a bug in this lib - do you think I changed the lib??? after two weeks of work? no... i have just forked this lib with my fix. this is an open source and you are a developer - or aren't you?
yes true. @Martinus1 can you do one of 2 things?
Either
- Upload a sample app with the bug so i can debug it or
- can we chat here? https://gitter.im/patchthecode/JTAppleCalendar