jivesoftware / PDTSimpleCalendar

A simple Calendar / Date Picker for iOS using UICollectionView

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Assertion failure in -[UICollectionView _createPreparedSupplementaryViewForElementOfKind:atIndexPath:withLayoutAttributes:applyAttributes:]

Dalein opened this issue · comments

I want to show calendar as a view in my viewController. I create caledarVC standart way:

 PDTSimpleCalendarViewController *calendarViewController = [[PDTSimpleCalendarViewController alloc] init];
    [calendarViewController setDelegate:self];
    calendarViewController.weekdayHeaderEnabled = YES;
    calendarViewController.weekdayTextType = PDTSimpleCalendarViewWeekdayTextTypeVeryShort;

But I show calendar VC like this:
[calendarViewController showInView:self.view animated:YES];

I added in PDTSimpleCalendarViewController.m this method:

- (void)showInView:(UIView *)aView animated:(BOOL)animated
{
    CGRect calendarFrame = self.view.frame;
    calendarFrame.origin.y = 64;
    calendarFrame.size.height = CGRectGetHeight(calendarFrame)/1.5;
    self.view.frame = calendarFrame;

    dispatch_async(dispatch_get_main_queue(), ^{
        [aView addSubview:self.view];
    });
}

In time when calendar appeared, error occurred:Assertion failure in -[UICollectionView _createPreparedSupplementaryViewForElementOfKind:atIndexPath:withLayoutAttributes:applyAttributes:]
How can I show calendar view like I want?

commented

If you want to display the calendar inside another VC view you should implement UIViewController containment.
https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/ImplementingaContainerViewController.html

Thanks! I had to understand it by myself