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

Warning when viewWillTransition is called #1314

Open
jokerham opened this issue Mar 4, 2021 · 0 comments
Open

Warning when viewWillTransition is called #1314

jokerham opened this issue Mar 4, 2021 · 0 comments

Comments

@jokerham
Copy link

jokerham commented Mar 4, 2021

(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

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

1 participant