Glow-Inc / GLCalendarView

A fully customizable calendar view acting as a date range picker
MIT License
855 stars 106 forks source link

Easier to select just one date range #14

Closed bensebborn closed 8 years ago

bensebborn commented 8 years ago

I'd like the user to be able to select only one date range

I can do this by returning NO from:

- (BOOL)calenderView:(GLCalendarView *)calendarView canAddRangeWithBeginDate:(NSDate *)beginDate
  return NO;

}

However, it's then quite difficult for the user to select a new range to replace the old without deleting.

What I'd ideally like to achieve, is when the user selects a date outside of the current range, the existing range is deleted, and a new range is started where they click.

Is that possible?

Thanks

ltebean commented 8 years ago

You could achieve it by:

- (BOOL)calenderView:(GLCalendarView *)calendarView canAddRangeWithBeginDate:(NSDate *)beginDate
{
    for (GLCalendarDateRange *range in calendarView.ranges) {
        [calendarView removeRange:range];
    }
    return YES;
}
ltebean commented 8 years ago

And you can find the demo here: https://github.com/Glow-Inc/GLCalendarView/tree/single-select