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

Selecting multiple dates #3

Open
sigmundfridge opened this issue May 27, 2013 · 13 comments
Open

Selecting multiple dates #3

sigmundfridge opened this issue May 27, 2013 · 13 comments

Comments

@sigmundfridge
Copy link

Hi,
Loving the calendar. I needed to select multiple dates. To do this I subclassed DFDatePickerView, and overwrote the following methods....

- (UICollectionView *) collectionView;
- (DFDatePickerDayCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath;
- (void) collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath: (NSIndexPath *)indexPath;
- (void) collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath;

Nothing to complicated, just adding/removing dates to an array and changing how a cell is displayed based on that array. Then I subclassed DFDatePickerViewController, and overwrote -(DFDatePickerView*) datePickerView to use my new subclass. An extra method in the protocol passes the array to the delegate.

This all worked fine when using it within your own dayFlow-sample project. Strangely, when moving the files over to my own project the calendar always opens 6 months in the past. I know you use +/- 6 months when first generating the collection view. However, I can't see why my project would start there, but the same code in your sample project starts in the middle (i.e. now).

I realise this is out of the scope of your project, but if you can think of any reasons why the same code in 2 apps would behave differently I would be very appreciative. Either way, I'd suggest considering allowing multiple dates to be selected, as it seems to be a gap in the 'market'.

@evadne
Copy link
Owner

evadne commented May 27, 2013

I think this is why — is there double initialization happening?

@evadne
Copy link
Owner

evadne commented May 27, 2013

Also would love to get a patch for multiple date selection — if we can work out a nice API this will be a great thing to have :) thanks for using DayFlow.

@ghost ghost assigned evadne May 27, 2013
@sigmundfridge
Copy link
Author

I can send you my code, but I am towards the amateur end of the spectrum so it might not be much use. It is potentially a very simple problem, but being relatively new to Objective C my subclassing is still a bit guesswork.

@evadne
Copy link
Owner

evadne commented May 27, 2013

I happen to have approximately 15 minutes — can you put me on the repo as a temporary collaborator?

@sigmundfridge
Copy link
Author

and thanks for the help, that definitely looks like the issue

@evadne
Copy link
Owner

evadne commented May 27, 2013

You can just tell the collection view to scroll to the middle (reuse that chunk of code in -viewWillMoveToSuperview:) in your view controller’s -viewWillAppear:. That might work.

@sigmundfridge
Copy link
Author

Sorry for the delay, I hadn't actually added a repo for it (as it was just something I was messing around with). I've uploaded it now, and added you as a collaborator. It is basically your sample project, so needs pod install (the podfile is already present). If you don't get a chance to look at it, I will take your advice and work on it later.

@sigmundfridge
Copy link
Author

That works in viewDidAppear but not 'will' . And obviously this causes a bit of a jump. It also seems that this isn't just an issue for my subclassing, but generally when initialising your view controller via the storyboard.

@evadne
Copy link
Owner

evadne commented May 28, 2013

Gotcha. Storyboard usage. I will look at that and try to make the date
scrolling less hacks.

On May 27, 2013, at 17:20, sigmundfridge notifications@github.com wrote:

That works in viewDidAppear but not 'will' . And obviously this causes a
bit of a jump. It also seems that this isn't just an issue for my
subclassing, but generally when initialising your view controller via the
storyboard.


Reply to this email directly or view it on
GitHubhttps://github.com//issues/3#issuecomment-18518949
.

@sigmundfridge
Copy link
Author

Hi again,
Finally got around to formalising multiple date selection, and I've added you as a contributor to the forked project. When you initialise the view controller you send a BOOL to determine if it's single or multiple date selection. It defaults to single. It seems like a pretty simple addition to me, but I might be missing some finer important points from your code.

@evadne
Copy link
Owner

evadne commented Nov 16, 2013

I think we shall just expose the underlying collection view as multiple
selection and adjust the public API correctly?

On Nov 17, 2013, at 2:19, sigmundfridge notifications@github.com wrote:

Hi again,
Finally got around to formalising multiple date selection, and I've added
you as a contributor to the forked project. When you initialise the view
controller you send a BOOL to determine if it's single or multiple date
selection. It defaults to single. It seems like a pretty simple addition to
me, but I might be missing some finer important points from your code.


Reply to this email directly or view it on
GitHubhttps://github.com//issues/3#issuecomment-28632397
.

@evadne
Copy link
Owner

evadne commented Nov 16, 2013

ALSO — if you send a pull request I’ll be so happy to review it formally :)

On Nov 17, 2013, at 2:19 AM, sigmundfridge notifications@github.com wrote:

Hi again,
Finally got around to formalising multiple date selection, and I've added you as a contributor to the forked project. When you initialise the view controller you send a BOOL to determine if it's single or multiple date selection. It defaults to single. It seems like a pretty simple addition to me, but I might be missing some finer important points from your code.


Reply to this email directly or view it on GitHub:
#3 (comment)

@sigmundfridge
Copy link
Author

I think that's basically what i did, but added a custom init to allow for single or multiple selection.

Sent from my iPad

On Nov 16, 2013, at 7:03 PM, "Evadne Wu" notifications@github.com wrote:

I think we shall just expose the underlying collection view as multiple
selection and adjust the public API correctly?

On Nov 17, 2013, at 2:19, sigmundfridge notifications@github.com wrote:

Hi again,
Finally got around to formalising multiple date selection, and I've added
you as a contributor to the forked project. When you initialise the view
controller you send a BOOL to determine if it's single or multiple date
selection. It defaults to single. It seems like a pretty simple addition to
me, but I might be missing some finer important points from your code.


Reply to this email directly or view it on
GitHubhttps://github.com//issues/3#issuecomment-28632397
.

Reply to this email directly or view it on GitHub.

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