-
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
Orientation change is reseting the days in the calendar #557
Comments
I have a function to help you in that area, but its has a small bug which was fixed by the master branch. put this in pod file
Then do You will be forced to add a new function called Once your update is complete, lets deal with the rotation problem. override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
let theDate = // the date you want the calendar to focus to on orientation change
calendarView.viewWillTransition(to: size, with: coordinator, anchorDate: theDate)
} let me know how it goes |
Thanks for your reply, how do I update master branch code? Can you please explain. |
I just did above. put this in pod file
Then do |
I did it but what should I add to the function func calendar(_ calendar: JTAppleCalendarView, willDisplay cell: JTAppleCell, forItemAt date: Date, cellState: CellState, indexPath: IndexPath) { |
can you join me here -> https://gitter.im/patchthecode/JTAppleCalendar |
I am experiencing this issue with version 7.1.5 (using Carthage). I added the Is it possible this bug has been reintroduced? |
|
It's a private repo so I can't easily share the full code base. It's running on iPhone 6s simulator (11.2) but also happens on a real device (also iPhone 6s on 11.2). Relevant code: set selected date func calendar(_ calendar: JTAppleCalendarView, didSelectDate date: Date, cell: JTAppleCell?, cellState: CellState) {
self.handleCellConfiguration(cell: cell, cellState: cellState, date: date)
self.selectedDate = date
} helper function (anchorDate is current selected date) override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
if self.calendarView != nil {
let theDate = self.selectedDate
NSLog("anchorDate: \(theDate)")
self.calendarView.viewWillTransition(to: size, with: coordinator, anchorDate: theDate)
}
} configure func configureCalendar(_ calendar: JTAppleCalendarView) -> ConfigurationParameters {
let current = Date()
guard
let startDate = self.calendar.date(byAdding: .year, value: -1, to: current),
let endDate = self.calendar.date(byAdding: .year, value: 2, to: current) else {
fatalError("Dates could not be calculated")
}
let parameters = ConfigurationParameters(startDate: startDate, endDate: endDate)
return parameters
} So after rotating the calendar shows januari 2017 (as configured using startDate) |
@patchthecode do you have enough information to debug this issue? Thanks in advance. |
sorry. i missed this. Wil debug this today. |
I am not experiencing the issue that you are facing. I have tried it in may way on my example project attached to this github project. And I cant reproduce it at all. |
Hi, initially I could not reproduce it either. I kept adding functionality in the example project from the real app. It turns out it starts happening when I added Variations in storyboard based on height. See this example project I have setup for you: https://github.com/SocialSchools/JTAppleCalendarRotationTest In the (main) storyboard, there is a Main Stack View, which is Vertical by default and Horizontal for compact height only. If I remove that variation, it works fine again. In the real app the events for the selected date is shown. I simplified that by only showing the selected date. |
ok. will take a look. |
I am seeing this issue too. I'll see if I can drum up an example project that replicates it. |
is the sample project I provided not applicable for you? https://github.com/SocialSchools/JTAppleCalendarRotationTest |
It is. I just got super busy this week. |
hi, sorry the comment was meant for @JettF. Take it easy, I am already glad you can look into it. |
@josjevv after looking at it, your project is applicable to me. My mistake. |
got the same error in case of device rotation. |
me too... |
checking this out today. I was tied up earlier. |
@josjevv sorry i took so long. I got really tied up on other projects. |
I am also experiencing this issue. Let me know if anyone found a work around. Thanks! |
I ran into this issue too and have a workaround for my situation that others are welcome to use.
This works in my case since I select a date (today) when the view is first loaded up. That means selectedDates is guaranteed to have at least one member and the calendar can simply scroll back to it and re-select that date during rotation or size changes. I am sure there is a more elegant solution that can be made in the internals of JTAppleCalendar, but works ok for my use case. P.S. Thank you for such an awesome library @patchthecode , I managed to get a full calendar UI up in just a few days (I was dreading making a custom collectionview)! |
@patchthecode Any chance this library will be getting a fix for this issue as it's quite annoying? The workaround of @msencenb above works, but I'd rather not include such a workaround in the first place. A major thanks as well from me for this awesome library, by the way; it's really great. |
@NickGaens |
An alternative to @msencenb's solution is:
This worked better in my case as I use the |
@jaybayley A sample app was given, above with demonstrated the bug. I have not found a fix yet (sort of caught up between more than one projects) |
I made an update to master branch. |
It looks like as soon as orientation changes, the calendar resets to the month of end date but does not change the month and year label. That is if I am in June 2017 in landscape and change it to portrait, the days reset to September 2017 but month and label stays as June 2017. How do I stop this from happening?
I am using version 7.0.6 with Swift 3.0
The text was updated successfully, but these errors were encountered: