Skip to content
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

Enable scrollToDate on year view #1055

Open
RomuloVHSYS opened this issue May 23, 2019 · 2 comments
Open

Enable scrollToDate on year view #1055

RomuloVHSYS opened this issue May 23, 2019 · 2 comments
Assignees

Comments

@RomuloVHSYS
Copy link

I want a scrollToDateor scrollToMonth method for the new Year View

So i can scroll to the month of my need

@RomuloVHSYS
Copy link
Author

With workaround without having an official method, i have implemented my own way to scroll to a specific Date:

func scroll(toDate date: Date, at: UICollectionView.ScrollPosition = .centeredVertically, animated: Bool = true, considerMonth: Bool = true){
        let yearToScroll = c.component(.year, from: date)
        let currentYear = c.component(.year, from: Date())
        let monthToScroll = considerMonth ? c.component(.month, from: date) : 0
        let itemIndex = (yearToScroll - (currentYear-100)) * 12 + (yearToScroll - (currentYear-100))+monthToScroll
        
        self.yearView.scrollToItem(at: IndexPath(item: itemIndex, section: 0), at: at, animated: animated)
    }

Maybe it can help you @patchthecode

@zero-tolerance0
Copy link

unfortunately function
self.yearView.scrollToItem(at: IndexPath(item: itemIndex, section: 0), at: at, animated: animated)
not scrolling calendarYear to specified IndePath

it is called and some strange action happens (in mili seconds of time) but calendarYear still starts from the very beginning (

scrollToItem func is definitely getting called since if I put very big row for IndexPath it crashes.

@patchthecode
macOs 10.14 Mojave
xcode 11.3
JtAppleCalendar github "patchthecode/JTAppleCalendar" "master"
using carthage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants