-
Notifications
You must be signed in to change notification settings - Fork 810
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
Buggy or unexpected behavior for current day text color #761
Comments
This behavior is not strange. Therefore you have to reset the cell properly. if Calendar.current.isDateInToday(date) {
text = red
} else {
text = black
} But all you are doing is setting to red. Therefore when cells are reused, all become red. |
Also, your willDisplayFunction looks strange. it should look more like this: (pasted from my example code) func calendar(_ calendar: JTAppleCalendarView, willDisplay cell: JTAppleCell, forItemAt date: Date, cellState: CellState, indexPath: IndexPath) {
let cell = cell as! DateCelltemplate
cell.dateLabel.text = cellState.text
handleCellConfiguration(cell: cell, cellState: cellState)
}
func calendar(_ calendar: JTAppleCalendarView, cellForItemAt date: Date, cellState: CellState, indexPath: IndexPath) -> JTAppleCell {
let cell = calendar.dequeueReusableCell(withReuseIdentifier: "DateCelltemplate", for: indexPath) as! DateCelltemplate
self.calendar(calendar, willDisplay: cell, forItemAt: date, cellState: cellState, indexPath: indexPath)
return cell
} Your |
closing this issue. Let me know if youre still having a problem |
ok. Im not using willDisplay-Method now. In cellForItem-Method I implemented this line of code to set the textColor:
This is working fine, but not at first run i.e. when user open the calendar, even though the code is executed at first run (I set some break points and checked it). After user tap on any cell on calendar or scroll etc .. , it is set correctly. I need to do it this way. As I have many CustomCells which are assigned accordingly to the calendar. Yet Today-Cell is an exception and need to be handled separately. Many thanks in advance.. |
are you sure this is run correctly on first run? cell.dateLabel.textColor = Calendar.current.isDateInToday(date) ? .red : cellTextColor
// convert to this
if Calendar.current.isDateInToday(date) {
cell.dateLabel.textColor = .red
} else {
cell.dateLabel.textColor = cellTextColor
} and let me know = |
Just tried it. Its the same behavior. For todays-Date it is executing on first run and textcolor ist set to red. Yet it is not set/visible in the calendar. |
do you have a sample project with just this problem alone in it that i can take a look at?. You can create a sample project demonstrating the error. and drag the zip file in this chat box. |
I will try to provide sample code soon. Thanks for the support. |
cool. |
I made a sample code. Following similar structure as in my code. Yet in sample code, it is working at first run. And I cant find the difference in implementation! I'll check again..
|
worked now :)
Where textColor is defined in CustomCalendarBaseCell as dynamic var for dateLabel.textColor. Many thanks and nice day |
Have a good one. |
@patchthecode how can I hide cell is not not current day in month ? because if I just only hide cellview but it still have space in month. |
@patchthecode thanks now it work 🥇 |
Running latest version 7.1.5
Hi,
Im getting an unexpected behavior by selecting the cell of current day. CalendarView behaves normally for each selection and de-selection. Yet by selecting the current day, the view starts to behave in a strange way.
The text color should be set to red for current day. Yet other cells are getting red too! I set a breakpoint on the line where the color is set, and it is only executed when day == today. So something intern in the library is mixing things up. As red text color is observed in other cells too! Please check code sample.
Similar behavior also observed if didSelectCell- Method is used to set the red text color.
Can u plz explain this behavior?
The text was updated successfully, but these errors were encountered: