Skip to content

Latest commit

 

History

History
26 lines (17 loc) · 1.07 KB

Handling Device Rotation.md

File metadata and controls

26 lines (17 loc) · 1.07 KB

Handling device rotation

Whenever the device orientation changes, you need to let the library know about it by calling this function

public func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator, anchorDate: Date?)

Typically, developers should add it to the viewWillTransition delegate function of their ViewController SubClass.

Here is an example of the usage:

override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
    let visibleDates = calendarView.visibleDates()
    calendarView.viewWillTransition(to: .zero, with: coordinator, anchorDate: visibleDates.monthDates.first?.date)
}

The library needs to know what date should be focused on the screen when the orientation changes. In the above code, the first visible monthDate was captured and used as the anchor focus date.

When the orientation change completes, that month’s date will be focused on the screen.

Next Steps

Learn more about scrolling modes