Closed CassianoMouraLeao closed 6 years ago
hmm. again, you are using UICOllectionViews/UITableviews. There is no need to loop through your datasource to set the cells. The function
func calendar(_ calendar: JTAppleCalendarView, cellForItemAt date: Date, cellState: CellState, indexPath: IndexPath) -> JTAppleCell
will be called for every cell.
func calendar(_ calendar: JTAppleCalendarView, cellForItemAt date: Date, cellState: CellState, indexPath: IndexPath) -> JTAppleCell {
let cell = calendar.dequeueReusableJTAppleCell(withReuseIdentifier: "CustomCell", for: indexPath) as! Calendar_CollectionViewCell
let year = Calendar.current.component(.year, from: date)
let month = Calendar.current.component(.month, from: date)
let day = Calendar.current.component(.day, from: date)
let yearFor = Calendar.current.component(.year, from: array[indexpath.item])
let monthFor = Calendar.current.component(.month, from: array[indexpath.item])
let dayFor = Calendar.current.component(.day, from: array[indexpath.item])
if year == yearFor && month == monthFor && day == dayFor {
cell.myImage.isHidden = false
} else {
cell.myImage.isHidden = true
}
return cell
}
let me know if this works
It doesn't work yet, because my array has 16 values and the indexPath work between 0 to 16 that is 17 and now I have this error: Fatal error: Index out of range. Can I change the value of indexPath? I need to change the 0 to 16 for 1 to 16.
ok. i just gave an example.
How it should be is like how i had in the example video.
The best structure to store events in is a Dictionary of the form [String : YourCustomEventObject]
If you need more information you can chat here -> https://gitter.im/patchthecode/JTAppleCalendar As it is faster than typing in the chat box.
In this code I can see just cells with
cell.myImage.isHidden = true
but when I debug my code pass at linecell.myImage.isHidden = false
twice but I cannot see the image in application.Can anyone help me? I think that is the same idea of "Cells are reused." but I don't know how I can resolve.