Jtapplecalendar: Visible scrolling when trying to start calendar at a certain date

Created on 13 Jan 2017  路  26Comments  路  Source: patchthecode/JTAppleCalendar

My calendar has a pretty broad range, starting about 10 years ago.

I want the calendar to be on the current date when it first appears, so I do calendarView.scrollToDate(Date()) at viewDidLoad().

When I go to the calendar's view controller, I can se the previous months flash very quickly, and then the current month shows up (even if I use animateScroll = false).

I didn't try it, but I think this question and some of its answers could be useful: http://stackoverflow.com/q/18087073/3539651

Maybe this too:
http://stackoverflow.com/a/26247477/3539651

Already Fixed on Master Branch

Most helpful comment

OK. i will look into this. Thanks for finding.

All 26 comments

OK. i will look into this. Thanks for finding.

I think I have now fixed this.

Awesome, thank you. :)
How about the orientation stuff, any news?

Almost done.
Just testing it now.

Cool, thanks! 馃帀

Issue resolved on version 7.0
Releasing Beta version this weekend.

Awesome, thank you! 馃憦

I hope it works well for you.
I used your idea. I provide a delegate when orientation changes willTransitionToSize
let's see how that goes.

@dbmrq does version 7.0 resolve the visible scrolling issue? I'm using version 7.0 and call calendarView.reloadData(with: Date(), animation: false) inside viewDidLoad but can also see the previous months quickly flash before showing the current month.

@z3bi hmm.. you are reloading data on viewDidLoad..
is there any reason we are reloading data on the view did load?

At this point, the calendar is not even setup yet. So reloading will not really do anything.
if your objective is to scroll to a date on view did load, then
remove this -> calendarView.reloadData(with: Date(), animation: false)
and replace it with this calendarView.scrollToDate(Date())
let me know if this helps?

@patchthecode same behavior, here is what I am doing now:

override func viewDidLoad() {
        super.viewDidLoad()

        calendarView.scrollToDate(Date(), triggerScrollToDateDelegate: true, animateScroll: false, preferredScrollPosition: nil, extraAddedOffset: 0) { 
            self.calendarView.selectDates([Date()], triggerSelectionDelegate: true, keepSelectionIfMultiSelectionAllowed: false)
        }
    }

@z3bi ok let me know how many years of date that you generate please?

I will try to re-create this issue on my end

@patchthecode I'm just doing one year prior to today until one year after today. I'll try to recreate it in a sample project for you.

@patchthecode here is a repo with an example https://github.com/z3bi/JTAppleCalendarExample

It can be hard to see it in the simulator, but it is consistently noticeable running on an iPhone 7. The flash is pretty brief, but I just wanted to see if perhaps I'm doing something incorrectly or if it's just unavoidable.

@z3bi as the original poster shows, this seems to be an issue with UICollectionView. I'm not sure of the best way to handle this. Therefore, for now, I have set the help wanted flag to this issue.

@z3bi on 2nd thought, i think i found something. I can set the content offset inside the prepare() function. Right now i am investigating the possible side effects.

I didn't get the chance to try version 7 yet, but if the UICollectionView itself is exposed maybe we could use some of the answers to the Stack Overflow questions I posted (the hack we talked about, @patchthecode). Not the most elegant solution, but it's something. I'll look into it as soon as I can.

@dbmrq thanks man. I'd really appreciate the help if you can

@z3bi can you let me know if this is a fix ?
JTAppleCalendarExample.zip

@patchthecode yeah that worked great, can't notice any dates changing when the view loads. 馃憤

@z3bi awesome i will look at the changes again, and then get a new build for 7.0.2 up
thanks for the assistance

@dbmrq seems i found something from the links you provided

Ah, awesome, I'm sorry I couldn't help more. I'll still take a look when I can, I've been really busy lately.

@dbmrq its cool man. You've a;ready helped quite a bit

@z3bi i just pushed the change to master branch. I hope i didnt break any thing :)
Seems well after i tested.

@patchthecode awesome, thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

oddpandadesign picture oddpandadesign  路  5Comments

programus picture programus  路  5Comments

VladFrolov picture VladFrolov  路  4Comments

Fatalution picture Fatalution  路  3Comments

dimitris-c picture dimitris-c  路  5Comments