JTAppleCalendar icon indicating copy to clipboard operation
JTAppleCalendar copied to clipboard

Warning when viewWillTransition is called

Open jokerham opened this issue 4 years ago • 0 comments

(Required) Version Number: 8.0.8 Xcode 12.4

Description

I wanted to implement your calendarView in a stack view that will change the axis when the device changes portrait/landscape. I have implemented viewWillTransition but with additional code to change the axis.

override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
    if UIDevice.current.orientation.isLandscape {
        stackView.axis = .horizontal
    } else {
        stackView.axis = .vertical
    }
    let visibleDates = calendarView.visibleDates()
    calendarView.viewWillTransition(to: .zero, with: coordinator, anchorDate: visibleDates.monthDates.first?.date)
}

Steps To Reproduce

When I change from portrait to landscape for the first time I do not see the calendar, and get following warnings.

2021-03-05 01:00:16.506620+0900 Planner[20505:7076287] [CollectionView] Layout attributes <UICollectionViewLayoutAttributes: 0x1049044d0> index path: (<NSIndexPath: 0xbbecb40e1586d644> {length = 2, path = 0 - 0}); frame = (0 0; 50.8571 48.3333); were received from the layout <JTAppleCalendar.JTACMonthLayout: 0x104835cc0> but are not valid for the data source counts. Attributes will be ignored.

After I return back to portrait, I still get the following warnings, but I can see the calendar.

2021-03-05 01:00:24.325120+0900 Planner[20505:7076287] [CollectionView] Layout attributes <UICollectionViewLayoutAttributes: 0x10483a880> index path: (<NSIndexPath: 0xbbecb40e1586d644> {length = 2, path = 0 - 0}); frame = (0 0; 50.8571 48.3333); were received from the layout <JTAppleCalendar.JTACMonthLayout: 0x104835cc0> but are not valid for the data source counts. Attributes will be ignored.

Subsequent transitions to landscape or portrait show no more warning and shows the calendar resized properly.

Expected Behavior

I would like to know why the warning are shown, and hope to fix the first transition where calendar is not shown.

Additional Context

You may refer to the code in the link below. https://github.com/jokerham/PlannerStoryboard

jokerham avatar Mar 04 '21 16:03 jokerham