Skip to content

Question - scrolling to wrong offset #211

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

Closed
roarapps opened this issue Nov 25, 2016 · 19 comments
Closed

Question - scrolling to wrong offset #211

roarapps opened this issue Nov 25, 2016 · 19 comments

Comments

@roarapps
Copy link

Hello,

Have an interesting one, i have my calendar set up to display 1 year either side of today. Everything is great, the calendar loads to today when i show it.

I have calendarView.allowsMultipleSelection = true, so user can select and deselect dates.

Issue -

  1. User selects date
  2. User scrolls back a month (either via button action, or swipe)
  3. I invoke deselectAllDates
  4. User scrolls forward a month
  5. Instead of going forward a month, it goes forward a month but last year.

Strangely, i can only replicate this on the iPad and not iPhone. This only happens when i invoke deselectAllDates.

I will look further into this tomorrow, do you know why this may be happening? I will need to step through code tomorrow but if you had a good place for me to start it would be helpful.

@patchthecode
Copy link
Owner

So you're saying that when the user does step #4, it scrolls backward a whole year instead of just scrolling forward normally? join me here if you are able to do so -> https://gitter.im/patchthecode/JTAppleCalendar

@patchthecode patchthecode changed the title Question - scrolling to wrong date Question - scrolling to wrong offset Nov 26, 2016
@patchthecode patchthecode self-assigned this Nov 26, 2016
@roarapps
Copy link
Author

Yup, im just about to head off to bed. I'll try to take a look tomorrow and provide more information. However, i may only get time to look at it on Monday.

@patchthecode
Copy link
Owner

patchthecode commented Nov 26, 2016

@roarapps alright then. I'll check with you later then.
I wish i could at least re-create it now though. See you on monday

@roarapps
Copy link
Author

Just some notes to remind me when i look at this again -

It scrolls backwards to the start of the calendar + 1 month. This seems like when i go Next, it thinks the current month is the start month.

It only happens if i have a date, or dates selected

It only happens one time, i have to reinit to replicate again.

@patchthecode
Copy link
Owner

patchthecode commented Nov 28, 2016

one thing to try.
Put this in your podfile, and let me know if this issue is also happening on the master branch.

pod 'JTAppleCalendar', :git => 'https://github.com/patchthecode/JTAppleCalendar.git'

Then do a:

pod install

on console

@roarapps
Copy link
Author

Okay, i'll try this in the afternoon (UK time) and report back

@roarapps
Copy link
Author

Hello, I was already on the master branch. I will try to replicate the issue using your example app to make sure its not anything obvious i'm doing wrong and report back

@patchthecode
Copy link
Owner

@roarapps ok if youre on master. Do a pod install because I had made some changes

@roarapps
Copy link
Author

Okay, haven't managed to replicate on your example project but on my project i've commented all excess code out so it's just the calendar view with basic code left.

I've did a pod install as well, if this line is commented out, there is no issue
"// If this cell is already selected, then deselect it
deSelectTheDate(sectionIndexPath)"

Just trying to figure out exactly where its going wrong.

@patchthecode
Copy link
Owner

alright. let me know.
If its happening with yours, and not mine, then maybe its an issue i am not seeing.

Can you tell be what you are doing in your viewDidLoad?
Paste your code here. It might be possible you are scrolling to a date and something isnt getting called on time? But I need to see your code to find out.

@roarapps
Copy link
Author

roarapps commented Nov 28, 2016

The only difference between our code now is that I have a splitview controller, but can't see how that would affect anything.

override func viewDidLoad() {
        super.viewDidLoad()
        
        self.navigationItem.title = "Calendar"
        calendarView.dataSource = self
        calendarView.delegate = self
        calendarView.registerCellViewXib(file: "CalendarCellView") // Registering your cell is manditory
        
        calendarView.scrollingMode = .stopAtEachCalendarFrameWidth
        calendarView.cellInset = CGPoint(x: 0, y: 0)
        calendarView.scrollToDate(Date())
        
        calendarView.allowsMultipleSelection = true
        
        dateFormatter.dateStyle = .medium
    }

@patchthecode
Copy link
Owner

join me here -> https://gitter.im/patchthecode/JTAppleCalendar

@roarapps
Copy link
Author

Sorry missed that message and was working on something else today, i will jump on that channel tomorrow

@roarapps
Copy link
Author

roarapps commented Dec 3, 2016

Can you supply an email where i can send a zip of an example project with this defect

@patchthecode
Copy link
Owner

patchthecode commented Dec 3, 2016

patchthecode@gmail.com

patchthecode added a commit that referenced this issue Dec 4, 2016
#211

Did not save offset beffore reloading.
@patchthecode
Copy link
Owner

patchthecode commented Dec 4, 2016

@roarapps

Hey man.
I updated the code. Can you do a pod install to get the latest master branch code?
Let me know if it works.

@patchthecode
Copy link
Owner

By the way, sometimes pod install fails to get the latest code. This is something I have noticed (or maybe i am not good at cocopod specs?)

Anyway, in case you do a pod install and your code still is not fix, delete the JTAppleCalendar pod and then run a pod install again to make sure 100% that you the updated code fix.

@roarapps
Copy link
Author

roarapps commented Dec 4, 2016

Same issue, i deleted the pod and cleaned project. Its definitely getting the latest. I emailed you the splitview controller project, were you able to replicate on there using iPad sim?

"Installing JTAppleCalendar (6.0.4)
Generating Pods project"

@patchthecode
Copy link
Owner

Yes i able to replicate the issue.
And resolved it with the fix.
Your code now works as expected.
join me here -> https://gitter.im/patchthecode/JTAppleCalendar

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

2 participants