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

Ranges turn into single selections #31

Open
wilkinnh opened this issue Sep 12, 2016 · 6 comments
Open

Ranges turn into single selections #31

wilkinnh opened this issue Sep 12, 2016 · 6 comments

Comments

@wilkinnh
Copy link

screenshot 2016-09-12 10 20 07

Not sure how to describe this, but sometimes the range shows correctly, and sometimes it shows up like the attached screenshot. I also noticed that if the range looked correct, then I scrolled the range off the screen, then scrolled back, some of these symptoms also showed up. Any thoughts?

@ltebean
Copy link
Contributor

ltebean commented Sep 13, 2016

Make sure all the calls to the calendar api are in the main thread

@wilkinnh
Copy link
Author

Yup, all calls are on the main thread. I'm not doing anything terribly complex, just setting a couple ranges and scrolling. Is anyone else seeing this issue?

@ltebean
Copy link
Contributor

ltebean commented Sep 14, 2016

Can you share me the code so I can check what's wrong with it.

@wilkinnh
Copy link
Author

wilkinnh commented Sep 14, 2016

Sure, thanks for the help! A good portion of this is boilerplate code I took from the example, and then I added some pre-defined ranges.

`- (void)viewDidLoad {
[super viewDidLoad];

self.calendarView = ({
    GLCalendarView *calendarView = [[GLCalendarView alloc] initWithFrame:CGRectZero];
    calendarView.firstDate = [[NSDate datesForCurrentWeek] firstObject];
    calendarView.lastDate = [calendarView.firstDate dateByAddingTimeInterval:TimeIntervalDay * 365];
    calendarView.delegate = self;

    [self.view addSubview:calendarView];

    [calendarView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.mas_topLayoutGuide);
        make.left.right.equalTo(self.view);
        make.bottom.equalTo(self.mas_bottomLayoutGuide);
    }];

    [calendarView layoutIfNeeded];
    [calendarView setNeedsLayout];

    NSInteger screenWidth = self.view.bounds.size.width;
    CGFloat paddingAll = screenWidth % 7 + 7;
    [GLCalendarView appearance].rowHeight = (screenWidth - paddingAll) / 7 + 3;
    [GLCalendarView appearance].padding = paddingAll / 2;

    [GLCalendarView appearance].weekDayTitleAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:8], NSForegroundColorAttributeName:[UIColor grayColor]};
    [GLCalendarView appearance].monthCoverAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:30]};

    [GLCalendarDayCell appearance].dayLabelAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:20], NSForegroundColorAttributeName:[UIColor colorWithHex:@"555555"]};
    [GLCalendarDayCell appearance].monthLabelAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:8]};

    [GLCalendarDayCell appearance].editCoverBorderWidth = 1;
    [GLCalendarDayCell appearance].editCoverBorderColor = [UIColor colorWithHex:@"366aac"];
    [GLCalendarDayCell appearance].editCoverPointSize = 14;

    [GLCalendarDayCell appearance].todayBackgroundColor = [UIColor colorWithHex:@"366aac"];
    [GLCalendarDayCell appearance].todayLabelAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:20]};

    [GLCalendarDayCell appearance].rangeDisplayMode = RANGE_DISPLAY_MODE_CONTINUOUS;

    if (self.program)
    {
        GLCalendarDateRange *range = [[GLCalendarDateRange alloc] init];
        range.beginDate = self.program.startDate;
        range.endDate = self.program.endDate;
        range.backgroundColor = [RLNavStyles defaultBackgroundColor];
        range.editable = NO;

        [calendarView addRange:range];

        [calendarView scrollToDate:self.program.startDate animated:NO];

        self.selectedRange = range;
    }

    for (RLProgram *scheduledProgram in self.session.programManager.scheduledPrograms)
    {
        if ([scheduledProgram.subID isEqualToString:self.program.subID] == NO)
        {
            GLCalendarDateRange *range = [[GLCalendarDateRange alloc] init];
            range.beginDate = scheduledProgram.startDate;
            range.endDate = scheduledProgram.endDate;
            range.backgroundColor = [[RLColorStyleKit prologueBlue01] colorWithAlphaComponent:0.2];
            range.editable = NO;

            [calendarView addRange:range];
        }
    }

    calendarView;
});

}`

@ltebean
Copy link
Contributor

ltebean commented Sep 14, 2016

Did you call [calenderView reload] in viewWillAppear? And remove these two lines in viewDidLoad

 [calendarView layoutIfNeeded];
 [calendarView setNeedsLayout];

@wilkinnh
Copy link
Author

No, I did not have [calendarView reload] in viewWillAppear, but I added it and I can still see the issue.

Regarding taking out those lines, if I remove them I get a crash:

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'negative sizes are not supported in the flow layout'

Just based on the behavior, this looks like this might be a cell reuse issue. Any other thoughts?

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

2 participants