kovpas/PMCalendar

Second time it change frame to the little one.

shmidt opened this issue · 3 comments

Hi Pavel!

Beautiful control!

My problem is that when I use it in tableView, first time it presents as it should,
but after it changes its frame to the little one and prints in console:
PMLOG: -[PMDaysView drawRect:] [Line 847] End
{{183, 44}, {47, 45}}
PMLOG: -[PMDaysView drawRect:] [Line 847] End
{{19, 44}, {6, -3}}

I use storyboard and static cells.
Do you have any thoughts how to fix it?

  • (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
    [_commentTV resignFirstResponder];
    [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
    [pmCC presentCalendarFromRect:CGRectZero
    inView:tableView.superview
    permittedArrowDirections:PMCalendarArrowDirectionAny
    animated:YES];

// [pmCC presentCalendarFromView:self//(UITableViewCell *)[self.tableView cellForRowAtIndexPath:indexPath]
// permittedArrowDirections:PMCalendarArrowDirectionAny
// animated:YES];
[self calendarController:pmCC didChangePeriod:pmCC.period];
}

Thank you!

Hi Dmitry,

First of all, thank you :).

Regarding the problem with tableview, it's a little bit unclear when this squeezing happens. After you press on one of the arrows, or on a second time you present a calendar?

Personally, I've never used PMCalendar neither with storyboards nor with static cells, so it might cause some problems. Does the same problem appears in the demo project which is enclosed to the component?

-p

Problem has to come up on a second time calendar is presenting.

Sample project works fine, no squeezing at all.

I solved this issue by nullifying controller each time it was used:

  • (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
    [_commentTV resignFirstResponder];
    [self.tableView deselectRowAtIndexPath:indexPath animated:YES];

    pmCC = [[PMCalendarController alloc] initWithThemeName:@"apple calendar"];

    pmCC.delegate = self;
    pmCC.mondayFirstDayOfWeek = YES;

    [pmCC presentCalendarFromRect:CGRectZero
    inView:tableView.superview
    permittedArrowDirections:PMCalendarArrowDirectionAny
    animated:YES];

    [self calendarController:pmCC didChangePeriod:pmCC.period];
    }

#pragma mark PMCalendarControllerDelegate methods

  • (void)calendarController:(PMCalendarController *)calendarController didChangePeriod:(PMPeriod *)newPeriod
    {
    _periodLabel.text = [NSString stringWithFormat:NSLocalizedString(@"From %@ To %@", nil)
    , [dateFormatter stringFromDate:newPeriod.startDate]
    , [dateFormatter stringFromDate:newPeriod.endDate]];
    pmCC = nil;
    }

Thanks for response :)

Good to know :). Thanks.