scrollToDate() does not account for UICollectionView sectionInset property
First - thanks for all your hard work on this calendar! I am using JTAppleCalendar 7.02.
Calling calendarView.scrollToDate(Date(), triggerScrollToDateDelegate: true, animateScroll: false) I noticed that the collection view was stopping between April & May. I played around with the extraAddedOffset and realized the issue was related to the Section Inset.
The offset amount I needed to move the view into the correct position was 160pt. This is because the offset for each section increases by 40 so for 4 sections (jan through apr), the offset must be increased by 40 for each month (160). I'm not sure if it was intentional or not but thought I should bring it up.
The solution for now is to either not use section inset or to multiply the Integer month by the total inset amount and set that as the extraAddedOffset.
see https://github.com/patchthecode/JTAppleCalendar/pull/420
OK. Let me know if i understand correctly.
- You have a horizontal calendar
- You have a horizontal section inset
- When you call
scrollToDatein this state, the calendar does not properly scroll to the date?
That is correct - I also tested with a vertical scroll calendar with the same result.
Same issue here. I can post pull request if you want.
I have the same problem. These are the images of the problem.
Todays date = 2017/07/18. If I call scrollToDate Today, this is what it happens.
- Start date = 2017/06/01

- Start date = 2017/05/01

- Start date = 2017/04/01

As you can see, further the start dates are from Today, the further the offset gets. When I tried the start date as 1900/01/01 the collection view was showing somewhere in year 2040. I think the "cellCache" height information is not updated properly. Has anyone found a solution to this problem?
Just realized that it shows correctly if I call the function twice. Wonder why.
@jokerham i will investigate this today.
Same issue. Hope you will fix it soon @patchthecode
I got caught up last week. I'll take a look in 11 hrs today.
Same issue, but I'm using vertical scroll. The date cells appear aligned to the left after the scroll, but pop back into place when manually scrolling. @patchthecode
Seems like the same problem comes up when using scrollToSegment. It does not consider the sectionInset, too.
Im using Swift 4.0 with JTAppleCalendar 7.1.3
Yes.. this issue is opened, but i never got around to looking at it. My time is to caught up. Let me take a look after work today ok.
Hi, this issue seems to be still here: https://www.dropbox.com/s/1wyab52q7vk6zck/JTAppleCalendar_insetsIssue.mp4?dl=0
Could you please fix? This is really important for me to have insets 🙂
Hey guys, i have finally gotten around to fixing this.
can you put this in your PodFile and run a pod update command?
pod 'JTAppleCalendar', :git => 'https://github.com/patchthecode/JTAppleCalendar.git', :branch => 'Fixes'
If it works well, i will merge this into the next release.
Works in my projet and in the example project 👍 Thank you very much, that was fast!
7.1.5 released
Still have this issue. Pod version 7.1.7. For now removed insets to avoid UI bugs.
I can confirm, have the same issue on current version
Can you tell me the setup you have? What does your inset look like?
I need know what is your exact setup so that i can re-create the UI bug.
Hi,
I am currently struggling with scrollToDate on viewDidLoad. What I am trying is to have fixed cell height and change calendarView height on scroll (generating cells till end of row to prevent gap between months for vertical scroll direction). The issue I have:
- in viewDidLoad I have to set scroll mode to .none, then scroll and set scroll mode .stopAtEachSection, otherwise it stops somewhere in the middle of section
- I want to have top and bottom insets on section (place for shadow effect). After scroll in viewDidLoad the insets are ignored - view shows up scrolled, but I have to scroll manually so it snaps correctly with top inset. Also "extraAddedOffset" is ignored during the scroll in viewDidLoad.
I am sorry if the code is confusing, I am working today already for 14hrs, I cant think much straight... Hope it helps!
(code in next comment - answering vie email ruined the format)