JTCalendar
JTCalendar copied to clipboard
Months don't snap to their edge
When flicking the calendar left / right between months the calendar does not always properly stop at the month's edge, it can go further, or not far enough. This leads to the menu view and the calendar itself being in a weird state.
Simulator: 5S running 8.4 JTCalendar: 2.1.4
I remember having this bug but I don't remember how I solve it and what was it's origin, I think it's coming from the menu view or the synchronisation between the menu view and the calendar. Can you create a repository with a project with the same configuration?
Try [calendar reloadAppearance] and [calendar repositionViews] in viewDidLayoutSubviews, that solved my for me.
hope this will help
@jonathantribouharet I will try and spike this out into a separate project I can upload here. But the setup is basically as simple as your examples.
@shieer must be part of the 1.x versions, in 2.x those are not public selectors.
But, when I perform them regardless, it seems to lessen how often the problem appears, but the problem still persists frequently enough to be blocking me from updating.
- (void)viewDidLayoutSubviews {
[_calendarMenu performSelector:@selector(repositionViews)];
[_calendarContent performSelector:@selector(repositionViews)];
}
Yes it's from 1.x version, event if repositionViews
method still exist, it's a full rewrite of the code.
If I can't reproduce the bug it's complicated to fix it for me. I wait until you create a repository with just this controller for debug it.
it is 1.x version, sorry, i didn't see you are on 2.x
Just wanted to "plus one" this and say that I've hit the same bug. I've tried to create a minimal reproducible example project, but I can't trigger the bug outside of my app.
@tomdalling @shieer @jlindenbaum check the pullrequest: #218. Hopefully works for your projects.
@palcalde I've replaced your fixes in my JTHorizontalCalendar - it doesn't seem to address the fix - I can go correctly in one direction, but after one or two swipes in the other direction the same issue reappears.
Here's a minimal reproduction project that shows the issue (see the README): https://github.com/tomdalling/JTCalendarBugReproduction
I tried PR #218, and it mostly works. It causes some weirdness when repeatedly tapping the "Next Month" button in the JTCalendarBugReproduction project. Tapping "Next Month" while the sliding animation is in progress slows down the animation.
I'm not sure if it fixes the exact issue I was having in my app. Some recent unrelated changes to my app seem to have made the bug disappear, although I'm not sure why.
Hey @tomdalling you are right, tapping multiple times on back works great but doing it in next month slows down the animation (at least doesn't break the calendar as before).
I've udpated the #218 with a new commit that allows tapping on next multiple times without slowing the animation. Check it out.
@tomdalling Thank you very much, I wasn't able to reproduce the bug.
I still don't know what exactly is the problem. I think it's when there is an interaction during the animation of the scrollview.
I may have a simple / dirty hack, after calling [_horizontalView loadPreviousPageWithAnimation];
or another method moving the scrollview call
[_horizontalView performSelector:@selector(repositionViews) withObject:nil];
This hack came from http://stackoverflow.com/questions/993280/how-to-detect-when-a-uiscrollview-has-finished-scrolling, I'm using it for UITableView
in specific cases.
It's call repositionViews
method (which is not public) but in the main thread and after the animation of the scrollview (a the end of a scroll for example because the delegate method cannot be used in some cases...).
I haven't found issues after applying the changes in #218.
Hi there, I have add some code it help a lot to let Months snap to their edge. Please help check I am not sure wether it will solve all problem or not, but after add this lines, I rarely see the problem or maybe I cannot reproduce the bug ? link: https://github.com/cvhong/JTCalendar/commit/350183375ca99d4199c39da7adceb5be5a9aa4cb
I get the problem as well. It happens when I call loadNextPageWithAnimation serveral time rapidly in succesion. The bug seem to be with the calculation of contentOffset. I figured out a temporary workaround anyway.