Skip to content
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

Missing delegate call. #96

Closed
Bashta opened this issue Jul 31, 2016 · 8 comments
Closed

Missing delegate call. #96

Bashta opened this issue Jul 31, 2016 · 8 comments

Comments

@Bashta
Copy link

Bashta commented Jul 31, 2016

Hi. You are missing a delegate call on this function.

public func scrollToDate(date: NSDate, triggerScrollToDateDelegate: Bool = true, animateScroll: Bool = true, preferredScrollPosition: UICollectionViewScrollPosition? = nil, completionHandler:(()->Void)? = nil)

On line 251 you are currently setting the

 self.triggerScrollToDateDelegate = triggerScrollToDateDelegate

but the delegate is never actually called. This cause programmatically scrolling date not allowing UI update.

 func calendar(calendar: JTAppleCalendarView, didScrollToDateSegmentStartingWithdate startDate: NSDate, endingWithDate endDate: NSDate)

I can throw a PR if that will make the fix faster.
Thanks for the awesome work done so far.

@patchthecode patchthecode self-assigned this Jul 31, 2016
@patchthecode
Copy link
Owner

patchthecode commented Jul 31, 2016

This is odd. It should be called.

I just tested calendarView.scrollToDate(NSDate()) on the sample project, and it does call the delegates.

Can you show me the one line of code you are using to scrollToDate?
Maybe I might get a clue from there.

Also, when you scroll, is there a visual scrolling animation?

@Bashta
Copy link
Author

Bashta commented Jul 31, 2016

@IBAction func nextMonthButtonTapped(sender: UIButton) {
        calendarView?.scrollToNextSegment(true, animateScroll: true, completionHandler: nil)
    }

   func setupCalendar() {
        formatter.dateFormat = "yyyy MM dd"
        testCalendar.timeZone = NSTimeZone(abbreviation: "GMT")!

        calendarView?.delegate = self
        calendarView?.dataSource = self
        calendarView?.registerCellViewXib(fileName: "DateCalendarCell")

        calendarView?.direction = .Horizontal
        calendarView?.cellInset = CGPoint(x: 0, y: 0)
        calendarView?.allowsMultipleSelection = false
        calendarView?.bufferTop = 0
        calendarView?.bufferBottom = 0
        calendarView?.firstDayOfWeek = .Sunday
        calendarView?.scrollEnabled = true
        calendarView?.pagingEnabled = true
        calendarView?.itemSize = nil
        calendarView?.cellSnapsToEdge = true
        calendarView?.reloadData()

        let currentDate = calendarView?.currentCalendarDateSegment() ?? (startDate:NSDate(), endDate: NSDate())
        self.setupViewsOfCalendar(currentDate.startDate, endDate: currentDate.endDate)
    }

The scroll is animating when user scrolls manually or taps the button. The delegate is called when user scrolls manually but not when taps the button.

Also on the sample project the scroll buttons are not working. if scrollInProgress { return } line 528 is always true.

@patchthecode
Copy link
Owner

wow.. that bug was introduced in last update.
Thanks for noting. I'll put in a patch.

@patchthecode patchthecode added bug and removed question labels Jul 31, 2016
@patchthecode
Copy link
Owner

Ok bug has been fixed. Just doing some testing.

@patchthecode
Copy link
Owner

Hey, I have pushed a fix to master branch. Are you able to test it?
If you are using cocoapods, you can test using these instructions

@patchthecode
Copy link
Owner

Btw, you can reduce your code to the following. Because in what you had previously, some are already the default.

        calendarView?.delegate = self
        calendarView?.dataSource = self
        calendarView?.registerCellViewXib(fileName: "DateCalendarCell")
        calendarView?.cellInset = CGPoint(x: 0, y: 0)
        calendarView?.reloadData()

@Bashta
Copy link
Author

Bashta commented Jul 31, 2016

@patchthecode Its working fine now. Thanks for the quick fix. The reason the for the default properties being left on the setup method is that we can quickly tinker the calendar since the app is still in rapid development. Te code will be cleaned up after we get a final design submit ;). Thanks again for the awesome job!

@Bashta Bashta closed this as completed Jul 31, 2016
@patchthecode
Copy link
Owner

patchthecode commented Jul 31, 2016

Got you. And Thanks :)

And since its working again, i'll release the official version this evening.

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