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

Add method for checking date visibility. Improve scrolling method to consider if header is pinned. #21

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

randomstep
Copy link

I wanted to check if a date is already displayed, so I know whether to scroll to it, or for example to hide the calendar if it is already in view.

I also wanted the scrolling to actually show the date itself, not just the month. So I made both my new method and the scrolling method check for pinning, and go to the exact row or the section based on whether header pinning is turned on.

Suggestions for refactoring out the duplicate code for checking pinsHeaderToTop? It bugs me but so does adding something like pinnedIndexPathForRowAtDate:. Could also do indexPathForRowAtDate:IgnorePinning: where the second argument is a BOOL on whether to use pinning or not. Or maybe is whether to return the header row for the month instead of the exact row. That doesn't seem like a great solution either.

@puls
Copy link
Owner

puls commented Apr 17, 2013

Check your indentation.

@randomstep
Copy link
Author

Fixed.

} else {
dateIndexPath = [self indexPathForRowAtDate:date];
}
[self.tableView scrollToRowAtIndexPath:dateIndexPath atScrollPosition:UITableViewScrollPositionTop animated:animated];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how I feel about this particular change, as it represents a break from backwards compatibility. Are you using a calendar view that's not big enough to display the whole month at once?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am, yes. I think deferring to "pinsHeaderToTop" makes consistent and expected behavior. Otherwise "scrollToDate" is just "scrollToMonth". I can see how it wouldn't matter so much if you display the whole month.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants