patchthecode / JTAppleCalendar

The Unofficial Apple iOS Swift Calendar View. Swift calendar Library. iOS calendar Control. 100% Customizable
https://patchthecode.com
MIT License
7.57k stars 812 forks source link

Calendar crashing on iOS 17 #1379

Closed dhawanheena26 closed 1 year ago

dhawanheena26 commented 1 year ago

UIKitCore 0x198c58 -[UICollectionViewData layoutAttributesForSupplementaryElementOfKind:atIndexPath:] UIKitCore 0x163520 -[UICollectionView _dequeueReusableViewOfKind:withIdentifier:forIndexPath:viewCategory:] UIKitCore 0x1d7a5c -[UICollectionView dequeueReusableSupplementaryViewOfKind:withReuseIdentifier:forIndexPath:]

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

**8.0.4**

Calendar crashes on iOS 17 beta on line dequeueReusableSupplementaryViewOfKind - month header view

App should not crash

patchthecode commented 1 year ago

is this production or dev?

i need more log info. The ones you posted is not sufficient to tell me anything.

Also, we have 8.0.5 version for the latest iOS. let me know

dhawanheena26 commented 1 year ago

We created a sample project to replicate this with version 8.0.5

Issues faced on this sample project:

  1. assert(false, "You have implemted a header size function, but forgot to implement the headerViewForDateRange function") - This causes crash, though we have implemented all required methods (size methods)
Screenshot 2023-08-18 at 1 55 28 PM

After commenting this assert function

  1. tried to implement calendarSizeForMonths but when I do, the app crashes with error "Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'request for layout attributes for supplementary view UICollectionElementKindSectionHeader in section 4 when there are only 0 sections in the collection view'"
Screenshot 2023-08-18 at 1 56 16 PM

Zip file for sample project : headersCrash.zip

patchthecode commented 1 year ago

According to the code you gave me, you didnt implement the function.

You have implemented this:

private func calendar(_ calendar: JTACMonthView, headerViewForDateRange range: (start: Date, end: Date), at indexPath: IndexPath) -> JTACMonthReusableView? {
// code ....
}

But the real function should instead be this:

func calendar(_ calendar: JTACMonthView, headerViewForDateRange range: (start: Date, end: Date), at indexPath: IndexPath) -> JTACMonthReusableView {
// code ...
}
patchthecode commented 1 year ago
  1. remove the private and set it as internal
  2. remove the optional return JTACMonthReusableView? and make it non optional JTACMonthReusableView