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

Set dotMarkers from JSON result #80

Open
wstudios opened this issue May 29, 2015 · 9 comments
Open

Set dotMarkers from JSON result #80

wstudios opened this issue May 29, 2015 · 9 comments

Comments

@wstudios
Copy link

Hi, I was wondering if anyone can help with this. I know how to get the json data which includes my dates . I have a delegate set in my controller that creates a model of the data and places it in an array. The problem I have is that the calendar gets finished long before the array is built so it remains a 0 count if I try to use inside the 'func dotMarker(shouldShowOnDayView dayView:'
Any help on getting the data before the calendar is drawn or adding the dotmarkers and refreshing would be great.
Thanks.

@MlM7Studios
Copy link

Hello,

I agree refreshing the dotMarkers at any time (after loading the view controller) according to our data, would be very helpful, not to say vital ! (see #47, #78 )

@avicooper1
Copy link

I tried this approach after my data was loaded, but it still does not reload the dots on the days that should have them.

On Jun 3, 2015, at 9:55 PM, Thomas Baldwin notifications@github.com wrote:

Have you tried just calling calendarView.commitCalendarViewUpdate() once your data is loaded? That function should refresh the calendar


Reply to this email directly or view it on GitHub #80 (comment).

@wstudios
Copy link
Author

ok, I found a solution that worked for me, maybe it will for others. As mentioned I am using protocol and delegate to load my data from a server but you can use any function that gets called in the viewDidLoad.
The first thing is to remove the code that loads the calendar. This was placed in the viewDidLayoutSubviews
calendarView.commitCalendarViewUpdate()
menuView.commitMenuViewUpdate()
Inside your function or delegate that gets the data, call the codes above to load the calendar. Place your data in an array and use that array in the dotMarker to set your markers.

This change does not technically reload the calendar but it does prevent the calendar from loading before getting the data.

@mozharovsky
Copy link
Member

Hello @wstudios, @matlamenace, @avicooper1,

Thank you for reporting the issue. I'll add support for reloading CVCalendar components in the upcoming maintenance.

Regards,
Eugene

@GioSkellington
Copy link

Hi @mozharovsky!
thank you for CVCalendar! It's great!

For this issue I found a solution that reload calendarView at run time.
I'm using a function in CVCalendarView class (similar at changeMode function) that I can call when JSON is parsed.

public func reloadMonthView(selectedDate: NSDate) {
            let newController: ContentController

            contentController.updateHeight(contentController.presentedMonthView.potentialSize.height, animated: true)
            newController = MonthContentViewController(calendarView: self, frame: bounds, presentedDate: selectedDate)

            newController.updateFrames(bounds)
            newController.scrollView.alpha = 0
            addSubview(newController.scrollView)

            UIView.animateWithDuration(0.5, delay: 0, options: UIViewAnimationOptions.CurveEaseInOut, animations: {
                self.contentController.scrollView.alpha = 0
                newController.scrollView.alpha = 1
                }) { _ in
                    self.contentController.scrollView.removeAllSubviews()
                    self.contentController.scrollView.removeFromSuperview()
                    self.contentController = newController
            }
    }

Hope this helps! :)

@mechdon
Copy link

mechdon commented Oct 9, 2015

Mozharovsky, has this issue been fixed? GioSkellington, I tried your method but it did not work. When I call this method and pass in the selectedDate, there was an error message which says "Cannot invoke 'reloadMonthView' with an argument list of type (NSDate)".

@mechdon
Copy link

mechdon commented Oct 9, 2015

GioSkellington, I managed now to call the function. However, the dotMarkers still do not update in the view.

@mechdon
Copy link

mechdon commented Oct 9, 2015

Hi GioSkellington, thanks very much for your solution. It works!

@gyanaprakash
Copy link

hot to show dotmark on a particular date in cvcalendar

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

7 participants