-
Notifications
You must be signed in to change notification settings - Fork 801
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
Given an array of saved dates, how to do i select a number of dates on the calendar? #1
Comments
Acknowledged your problem. Will give you a response in some hours. |
@antonijap Ok. As i'm the sole dev on this project, I missed this obvious feature. Thanks for pointing it out to me. I now have the code for this updated and i'm now reviewing it before i commit it. Was there any other part of this project you found to be missing? It's always good to have more eyes. |
For now, this is the only thing that was missing. If I find anything else I'll let you know. Thanks for being so quick with this issue. |
Description of the fix: --> func selectDate(date: NSDate) will be changed to func selectDate(date: [NSDate]) So let's say you have a bunch of dates saved from some time before. You can use like this: let d1 = someDate...
let d2 = someDate...
let d3 = someDate...
calendarView.selectDate([d1, d2, d3]) This will cause your dates to be selected. If your date is off the screen, it will still be selected. Does this proposed fix sound like it will meet your needs? |
I think it will be great. Let me show you my code:
Basically, when a user taps on certain dates they will be stored in my database, and then they should be permanently displayed as selected dates on a calendar. User can deselect it and they will be erased from a database. Can you just explain a bit how should I use updated function with my code? |
The function isnt updated yet. I have not pushed the changes yet. I am currently testing it to make sure i didnt break anything :) . But I will be pushing it in some hours. Now in regards to how you will use it, here are some things.
// Grab selected dates from database, select it
for day in demoDays {
let blah = c.dateFromString(day)
if date.isEqualToDate(blah!) {
dayLabel.text = "YES" // Just for testing, delete this
// make them selectable
}
} Keep in mind the calendarView is just like a UITableView. Just like in a UITableView, the cellForRowAtIndexPath will be called for every cell, it will be the same for this calendarView. Therefore the setupCellBeforeDisplay function will be called before every cell is displayed. The function is meant to give you some time to setup the dayCell's visual looks before it is displayed. Are you sure you want to put a loop in that function that takes information from a database? Remember, setting up a cell should be fast.
// Grab selected dates from database, select it
for day in demoDays {
let blah = c.dateFromString(day)
if date.isEqualToDate(blah!) {
dayLabel.text = "YES" // Just for testing, delete this
// make them selectable
calendarView.selectDate([blah])
}
} or you can gather them to be selected all at once. Like so: // Grab selected dates from database, select it
var datesToBeSelected: [NSDate] = []
for day in demoDays {
let blah = c.dateFromString(day)
if date.isEqualToDate(blah!) {
dayLabel.text = "YES" // Just for testing, delete this
// make them selectable
datesToBeSelected.append(blah)
}
}
calendarView.selectDate(datesToBeSelected) |
I played with "old" function |
Alright then. I will still do the update however. The selecting of the date with the old function will only work if the date is visible on the screen. You will have to scroll to the date first before selecting it. Like so: calendarView.scrollToDate(someDate) After the new code is updated however, selecting a date will work even if the date is not visible on screen. Will update code in some some hours. Cheers. |
Code committed. You can check it out now. It is now version 2.0.0 (so you can put that in your Pod file if you are using cocoapods) |
Ok. As i've said in the last message. I have decided to leave the function with the same name. Therefore, to use do just like you have done.
If you need to select multiple dates, you can select this like so:
I did not want to break the functionality of method by changing its signature to accept an array or dates. |
Tomorrow, i will also commit a new function called: This one will behave the way like we have discussed. But for now, use the function in a loop like I showed you above. |
Oh sorry, I didn't gather that part. Well, untill tomorrow... |
Committed. Do update on version 2.0.1. |
Ok, I tested it, it works. Thanks! |
Hey, im seeing this message in my email -> "I don't know if it's something in my code but didSelectDate is not working as expected. When I click nothing happens, if I scroll forward and then get back to month where selected date is - then it shows." But im not seeing this message here. Are you experiencing difficulty? or was that an old email. |
I deleted it because I found a way to make everything work. I attached delegate and datasource on my view controller and it didn't work right, then I made extension and now it works. |
I think i know why it wasnt working for you. I suspect you didnt look at the release notes for 2.0.1. Notice there is an added --> ? after the JTAppleDayCellView. This is the only major change made in 2.0.0 that can break functionality. |
Just to let you know selectDates is not working well with Firebase. I have reading data and displaying it on a calendar in my viewDidLoad. I'm using So, in my Firebase block of code I have |
To show you problem in a simple form, this is a code that happens when the app loads:
And this is a code in
AND when I open my app, without touching anything, console says:
Maybe you intended to connect these two functions but it is impossible to work with multiple dates in a database when |
So just to be clear, you want to select a date, but you only want the didSelectDate to be triggered only when a user taps on it, and not when youre just trying to setup the initial data? |
Yes, if it's possible. Because when I load initial data |
As this is a new issue i've created a new Issue here -> #4 Expect a fix in some hours. |
You're really quick. As you are better programmer than me I can't offer you help with that but if you want super-cool logo for your calendar or something like that - I'm here. |
Ah cool. Well, i'm not much of a designer, so i just whipped one up before creating this app. Since i'm already so attached to the one i created, it will be sad to part with it. But i wont refuse a logo if you create one that looks awesome. But no pressure. It's up to you :) |
Hello, |
@tosifkanuga |
My problem is solve
…On 14 Oct 2017 9:05 p.m., "JTAppleCalendar" ***@***.***> wrote:
@tosifkanuga <https://github.com/tosifkanuga>
let me know if this discussion helped -> #252
<#252>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AUQUTjb3wROIzSx-4aE_zwQPLELhhLTHks5ssNTJgaJpZM4IAeRP>
.
|
awesome :) |
Thank you for your response
…On 14 Oct 2017 9:08 p.m., "JTAppleCalendar" ***@***.***> wrote:
awesome :)
cool 🍻
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AUQUTvjqk6YRAEDti9uyyne3j27wuqo4ks5ssNWEgaJpZM4IAeRP>
.
|
hey.. I want select dates when calendar is load ...n I used selectdates() bt last date will be selected ...I used for loop then all dates are selected....but problem is when I scrolled then all selected dates are gone |
@axita27 what code did you use to select the dates? |
func setupViewsOfCalendar(from visibleDates: DateSegmentInfo){ this function is called in didScrollToDateSegmentWith method |
that is not how to select multiple dates. self.calendarView.selectDates(self.arr) |
@axita27 I do not understand what you area asking. |
ohhh....I just want to select my array dates....n not select other dates... |
calendarView.allowsMultipleSelection = true
self.calendarView.selectDates(self.arr)
Is this something you want? or is this something you do not want? |
yes I don't want when I scrolled multiple time current month to other month then one of my array date unselected automatically |
@axita27 can you join me here? https://gitter.im/patchthecode/JTAppleCalendar |
yes |
I have an array of dates (that user previously tapped) and I'm trying display them on a calendar by assigning them isSelected = true, but I can't because Xcode tells me isSelected is a let.
Is there some workaround to this?
The text was updated successfully, but these errors were encountered: