CalendarKit icon indicating copy to clipboard operation
CalendarKit copied to clipboard

move(to: ) forcing timeline view to 12:00 am

Open drouston opened this issue 6 years ago • 5 comments

New Issue Checklist

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.

drouston avatar Jun 20 '19 22:06 drouston

Quick clarification: the iOS example has this behavior when

autoScrollToFirstEvent = false

Thanks.

drouston avatar Jun 21 '19 16:06 drouston

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.

drouston avatar Jun 26 '19 21:06 drouston

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()
        
    }


}

VagueAcademicEland-size_restricted

edits: removed requestData() from code as it was not necessary, added swipe gesture observations

drouston avatar Jun 27 '19 21:06 drouston

Hello @richardtop, just following up on this one. Any news?

Thanks.

drouston avatar Aug 02 '19 13:08 drouston

This is a known bug in the library. Thank you for reporting it.

richardtop avatar Dec 18 '19 22:12 richardtop