Jtapplecalendar: overriding scrollViewWillEndDragging for fast scrolling

Created on 20 Oct 2016  路  4Comments  路  Source: patchthecode/JTAppleCalendar

Hi, I want to know if it is possible, and in case it is, how to do it, to override the method scrollViewWillEndDragging. I need to do this because I want to do some UI updates before scrollViewDidEndDecelerating gets called, for example, when user makes fast scrolling. Is there any way to do this?
Thanks and congratulations for this great work!

question

All 4 comments

Thanks.
Which version are you using? 5.0.1 or 6.0.0 ?

If you're using version 6.0.0, then there has to be an upgrade to it for it to happen.
Can you do a pull request and submit it? I will approve it.

Here is the change you need to do -->
in the UIScrollViewDelegates.swift file, you will see a function called

 public func scrollViewWillEndDragging(_ scrollView: UIScrollView,
        withVelocity velocity: CGPoint,
        targetContentOffset: UnsafeMutablePointer<CGPoint>)

all you have to do is change it to this and submit a request. That's it for the library side of things.

 open func scrollViewWillEndDragging(_ scrollView: UIScrollView,
        withVelocity velocity: CGPoint,
        targetContentOffset: UnsafeMutablePointer<CGPoint>)

Now in your code, you just have to create your own custom calendar and use it (instead of mines), and override that function. Thats it.

For example you would my use this as your calendar:

class myCustomCalendar: JTAppleCalendarView {
    public override func scrollViewWillEndDragging(_ scrollView: UIScrollView,
                                          withVelocity velocity: CGPoint,
                                          targetContentOffset: UnsafeMutablePointer<CGPoint>) {
        print("This will be executed before my didEnd code")
        super.scrollViewWillEndDragging(scrollView, withVelocity: velocity, targetContentOffset: targetContentOffset)
        print("This will be executed after my didEnd code")
    }
}

You will now need to use myCustomCalendar in your app. Change the calendar type on Storyboard to your new myCustomCalendar type. And make sure you delete the module text as shown below.

screen shot 2016-10-20 at 8 48 23 am

Also, if you're using version 5.0.1, you need to do the same steps. They might be a little different because 5.0.1 is in swift 2 while 6.0.0 is in swift3. In you're using 5.0.1 however, you do not need to do a pull request.

Finally, please leave a star rating on this repository if it has help you in anyway. Its needed for this project :)

Some time has passed and no response. I will assume this is corrected.
If you are still having issues, then feel free to re-open this request.

sorry for not responding. Finally I got to do what I was trying by adding a different header than I had previously. Thank you anyway

Cool. Have a good one.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Geekbell picture Geekbell  路  4Comments

Fatalution picture Fatalution  路  3Comments

MoridinBG picture MoridinBG  路  5Comments

oddpandadesign picture oddpandadesign  路  5Comments

dbmrq picture dbmrq  路  5Comments