Hi!
First congratulation and thanks for the awesome job with this library.
Using version 7.1.4
OK,
So, I have a datePicker to select the startDate and the endDate. When the user changes either one, I'm calling reloadData() on the calendar. When I modify the startDate the calendar works as expected.
Now, when I change the endDate and call reloadData()
developerError is called in this part of the code of the collectionView numberOfItemsInSection
public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
if calendarViewLayout.cellCache.isEmpty {return 0}
guard let count = calendarViewLayout.cellCache[section]?.count else {
developerError(string: "cellCacheSection does not exist.")
return 0
}
return count
}
Any idea of what's happening? Is there a correct way of updating dynamically the calendar view?
hmm. this should not be happening.
Let me try to replicate this on my sample app.
Will respond here in a bit.
Hey I just tested this on the sample application I have, and i cannot reproduce you issue.
Do you have a zipped empty sample app that can demonstrate the issue? You can drop it in this chat box or send to [email protected]
Okay so I found my problem.
I had in layoutSubviews() this code
self.calendarView.ibCalendarDelegate = self
self.calendarView.ibCalendarDataSource = self
So I figured out that that may be the problem and I changed it to
// Set Calendar Delegates
if self.calendarView.ibCalendarDelegate == nil && self.calendarView.ibCalendarDataSource == nil {
self.calendarView.ibCalendarDelegate = self
self.calendarView.ibCalendarDataSource = self
}
And problem solved!
To give a little of context, I have this code in layoutSubviews() because I was having problems with awakeFromNib being called before one of my variables be initialized (the calendar is inside a table view cell).
Sorry for taking your time. Hope this helps someone.
Its cool.
good its fixed.
So I figured out that that may be the problem and I changed it to
// Set Calendar Delegates if self.calendarView.ibCalendarDelegate == nil && self.calendarView.ibCalendarDataSource == nil { self.calendarView.ibCalendarDelegate = self self.calendarView.ibCalendarDataSource = self }And problem solved!
highly appreciate for this solution, faced same issue, now it works the way i needed.
p.s. finally found out this thread after a variety of search queries to find out what i need.
Most helpful comment
Okay so I found my problem.
I had in layoutSubviews() this code
So I figured out that that may be the problem and I changed it to
And problem solved!
To give a little of context, I have this code in layoutSubviews() because I was having problems with awakeFromNib being called before one of my variables be initialized (the calendar is inside a table view cell).
Sorry for taking your time. Hope this helps someone.