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

minimumDateForCalendar not working #495

Closed
cicerohellmann opened this issue Nov 23, 2016 · 5 comments
Closed

minimumDateForCalendar not working #495

cicerohellmann opened this issue Nov 23, 2016 · 5 comments

Comments

@cicerohellmann
Copy link

Hello. I'm using FSCalendar using Swift 2.3 and I'm in the 'FSCalendar', '2.3.3'. Xcode 7.3.1.
I can't get the minimumDateForCalendar to work.
I tried in a lot of ways:

func minimumDateForCalendar(calendar: FSCalendar) -> NSDate {
          let date = NSDate()
          return date
}

func minimumDateForCalendar(calendar: FSCalendar) -> NSDate {
    let date = NSDate()
	let calendarTemp = NSCalendar.currentCalendar()
	let day = calendarTemp.components(.Day, fromDate: date)
	let month = calendarTemp.components(.Month, fromDate: date)
	let year = calendarTemp.components(.Year, fromDate: date)
	return calendar.dateWithYear(year.year, month: month.month, day: day.day)
}

func minimumDateForCalendar(calendar: FSCalendar) -> NSDate {
    return calendar.dateWithYear(2016, month: 11, day: 22)
}

None seem to work. This is my class header:

class CalendarViewController: UIViewController, FSCalendarDataSource, FSCalendarDelegate
This is happening in any device I try.
I already tried some weird stuff.

The way the calendar is declared is this:

@IBOutlet weak var calendar: FSCalendar!

and it's bound to a calendar in my Storyboard.

There is no crashes, I used a breakpoint to make sure the method is not even being accessed. And when I try to type the method name it's auto complete work so I believe I'm importing the right stuff.

If you need any more information about this problem, please let me know, I really wan't to use youre lib
:)

@WenchaoD
Copy link
Owner

Hi @cicerohellmann. Have you linked the dataSource property from Storyboard correctly?

@JasonPan
Copy link

JasonPan commented Nov 27, 2016

Hi @WenchaoD. I'm having the same issue (tried linking the dataSource property both through code and the storyboard, to no avail). It's still allowing me to select a date "older" than the one specified in my minimumDateForCalendar! I can see that the minimum month is correct, and that it has greyed out the older dates - is this the intended behaviour? Is there a way to disable selection of these dates, if this is the case?

Please let me know if I can help further (i.e. more info).

Thanks for the great component!

@JasonPan
Copy link

JasonPan commented Nov 27, 2016

Aha! I found that I can achieve my required behaviour using shouldSelectDate (and checking whether the date is less than the minimumDate. I still don't understand why this isn't the default behaviour?

@JasonPan
Copy link

Also, as a side note, I noticed that setting the delegate or dataSource properties via code don't seem to take effect - only through the storyboard. Is this behaviour intentional?

@WenchaoD
Copy link
Owner

@JasonPan About the selection behavior, it is appended as default now, thanks for the proposal.
About delegate problem, please check your code again. And make a line-to-line comparison with the example if necessary. Thanks.

And I'll add specific example for Swift2.3 later.

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

No branches or pull requests

3 participants