CalendarKit
CalendarKit copied to clipboard
move(to: ) forcing timeline view to 12:00 am
New Issue Checklist
- [x] Use the latest version of CalendarKit
- [x] I've read the Contribution Guidelines
- [x] I've searched for existing GitHub issues
Issue Description
When I call dayView.state?.move(to: ) the subsequent timeline view resets to 12:00 am. I'd like for the position of the scroll view not to change, just as in the provided example. I am calling from within a delegate function of another library for a calendar cell selection. The scrollTo(hour24: ) and scrollToFirstEventIfNeeded() functions will work but only after the reset to 12:00 am.
I'm using just a DayView rather than a DayViewController. I've removed the extraneous code (I think...).
Thanks.
Code I'm using with CalendarKit
@IBOutlet weak var dayView: DayView!
override func viewDidLoad() {
super.viewDidLoad()
self.dayView.isHeaderViewVisible = false
self.dayView.dataSource = self
self.dayView.delegate = self
self.dayView.reloadData()
}
override func viewDidAppear(_ animated: Bool) {
self.dayView.scrollToFirstEventIfNeeded() //This scroll func works great
}
func calendar(didSelectDate date: Date) {
self.dayView.state?.move(to: date)
}
Result I am trying to achieve
See behavior in the iOS example.
Quick clarification: the iOS example has this behavior when
autoScrollToFirstEvent = false
Thanks.
Updates:
- I set
dayView.isHeaderViewVisible = true
and attempted to tap the dates in the header view. I observed the same behavior with the day view resetting to 0:00 hrs.
-
I've removed and reinstalled the pods for CalendarKit and dependencies for a clean install. No change.
-
I attempted to modify the date in move(to:) to include hour and minute components equal to the previous date. No change.
The swipe gesture on the day view maintains the same time as the previous page view. My guess at this point is this has something to do either with using the DayView as a subview or that I've setup the view controller in Interface Builder.
I was able to recreate the problem in a new project workspace with a clean install. My steps were only to have the ViewController class inherit from DayViewController. See code snippet for all lines of code in ViewController.swift and see the gif for behavior. The swipe gestures work fine and actually have a bit of nuance to the resulting page views; it seems to remember the vertical scroll position of the last view if swiped straight back to it. My best guess with the date selection at this point is it is related to the IB storyboard implementation of the paging scroll view. Maybe it is just starting at the top of the frame with a newly drawn view? It would be nice to resolve this as I would like to use CalendarKit in IB with related views for the calendars and events.
I'm a bit new to coding, and posting on github, so apologies if I'm using the wrong terms. I've probably hit the limit of my time commitment to this issue so I may not update anymore, or at least for a while. Any help is appreciated! 🙏🏼 thanks.
import UIKit
import CalendarKit
class ViewController: DayViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
}

edits: removed requestData() from code as it was not necessary, added swipe gesture observations
Hello @richardtop, just following up on this one. Any news?
Thanks.
This is a known bug in the library. Thank you for reporting it.