Open LondonAtlas opened 5 years ago
can you try writing this in your viewController?
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
let visibleDates = calendarView.visibleDates()
calendarView.viewWillTransition(to: .zero, with: coordinator, anchorDate: visibleDates.monthDates.first?.date)
}
and remove the trait code.
Thank you for replying so fast!
I updated but the issues remain. Also now when going from the largest width to the smallest the date shifts. For example, if I am looking at August 2019 and make the width smaller the dates shift to April 2001, which was my reasoning for the reload calendar method.
hmm. that function i gave you was supposed to do it. Is it possible you can provide a sample iPad project replicating the issue?
you do not have to design it or any thing. i'll see how i can fix on my end.
For personal pride I must tell you that I don't throw all my code into a single view controller file lol.
Thank you again for taking a look. The easiest way to replicate is to tap a date, while the detail view is present expand or compress the app and then navigate back to the calendar.
Is there anything I can do to help fix this issue?
Apologies. I missed this issue.. taking a look. (got caught up between projects)
My observations
With the split view, the cells resize correctly with the code i gave you ✅
With the code i gave you, (without and plist view), if you just rotate the calendar horizontally, and then vertically, it snaps to an incorrect date ❗️
This behaviour is incorrect. Investigating if this was introduced with the iOS 13.
As a work around, can you give the calendar's bottom constraint an explicit height, instead of making it dynamically reach the bottom of the viewController?
Apologies for the long delay. I have set the bottom constraint to the safe area of the superview but rotating the device still results in the date offset being wrong.
I have also tried forcing a height during viewWillAppear, and updating the height constraint viewWillTransition and traitCollectionDidChange but now when I rotate to landscape or portraiture calendar's dates don't fit into the new size.
@LondonAtlas I'm able to successfully resize my calendar after adding these lines to the viewWillTransition function:
DispatchQueue.main.async {
self.calendar.viewWillTransition(to: CGSize(width: .zero, height: self.calendar.frame.width), with: coordinator, anchorDate: visibleDates.monthDates.first?.date)
}
(Required) Version Number: JTAppleCalendar: 7.1.7 (need to support iOS 12) ipadOS (iOS 13) iPad 11" Simulator iOS 12.4
Description
Calendar doesn't resize cells correctly when transitioning from compactWidth/RegularHeight to RegularWidth/RegularHeight and vice versa.
I am also using the dates to show another view when didSelect is fired. If I adjust the app frame and the tap back to return to the calendar, the layout is also incorrect.
Steps To Reproduce
Use an iPad and add a second app like safari. Rotate iPad so that it is in the landscape orientation Adjust the size of the two apps so the calendar goes from compactWidth/RegularHeight to RegularWidth/RegularHeight (slimmest to widest while a second app is present)
Expected Behavior
Calendar resizes cells so that they fit from edge to edge of the collection view.
Additional Context
UI is laid out using a storyboard with top, bottom, leading, trailing constraints with top, leading, and trailing being set to edges of the viewController's view/ calendar superview.
I have tried calling invalidateLayout on the calendar's collectionViewLayout in the traitCollectionDidChange function but the same problem continues.
In viewDidLoad() I have this set up code:
I have also implemented the following as per the common issues section in the wiki.
P.s. My hunch is I have missed a critical step but after reading the how to create a calendar several times I don't know what I am missing.