jivesoftware / PDTSimpleCalendar

A simple Calendar / Date Picker for iOS using UICollectionView

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bad Layout when setting selectedDate

Nithos opened this issue · comments

Hi,

I am trying to use the component but are having some difficulties with the selected date. Wondering if someone can point me in the right direction, or show me what I am doing wrong. The issue is that when I initialize I want to set the selected date, but when I do the calendar is all wrong, see screenshot. When I just set the first and last dates it is fine but obviously no date has been selected. So wondering what I am doing wrong when I try to set the selected date on startup.

This is the basic code that I am using and not sure if there is something I am doing wrong here, so any help would be appreciated.

PDTSimpleCalendarViewController *calendarController = [[PDTSimpleCalendarViewController alloc] init];
        [self.calendarDelegate setValidDates:validDates];

        [calendarController setDelegate:self.calendarDelegate];

        if (validDates != nil) {
            [calendarController setLastDate:validDates[0]]; //[NSDate date]];
            [calendarController setFirstDate:validDates[validDates.count-1]];   // The last date in the list of valid dates is the first date for the calendar.
        }
        //This causes the weird graphical issue
        [calendarController setSelectedDate:[dataSource reportAsOfDate]];
//        [calendarController scrollToSelectedDate:NO];
        self.calendarPopover = [[UIPopoverController alloc] initWithContentViewController:calendarController];
        [self.calendarDelegate parentPopover:self.calendarPopover];

Thank You

image

commented

What's happening if you try to select the date after instantiating the popover?

My guess is : You're selecting the date before the calendar has actually been drawn on screen and contained in a popover, so its bounds at that time is the whole screen.
Then it's display in a popover but do not render properly.

Let me know if setting the selected date after the popover solves the issue, and if yes let's try to see why we don't relayout when changing the bounds.

commented

As mentioned by @IanHoar, you may wanna try again with latest master.

There is a little bit of a delay in redrawing the view (the enlarged view is still seen for a fraction of a second) but @IanHoar seems to have resolved the issue overall.

👍

Thank You guys,
We integrated your latest and so far are not seeing issues.

Thanks