<!--
{
  "availability" : [
    "iOS: 2.0.0 - 8.0.0",
    "iPadOS: 2.0.0 - 8.0.0",
    "macCatalyst: 13.1.0 - 13.1.0"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIViewController/willRotate(to:duration:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIViewController(im)willRotateToInterfaceOrientation:duration:"
  },
  "title" : "willRotate(to:duration:)"
}
-->

# willRotate(to:duration:)

Sent to the view controller just before the user interface begins rotating.

```
func willRotate(to toInterfaceOrientation: UIInterfaceOrientation, duration: TimeInterval)
```

## Parameters

`toInterfaceOrientation`

The new orientation for the user interface. The possible values are described in [`UIInterfaceOrientation`](/documentation/UIKit/UIInterfaceOrientation).

`duration`

The duration of the pending rotation, measured in seconds.

## Discussion

Subclasses may override this method to perform additional actions immediately prior to the rotation. For example, you might use this method to disable view interactions, stop media playback, or temporarily turn off expensive drawing or live updates. You might also use it to swap the current view for one that reflects the new interface orientation. When this method is called, the [`interfaceOrientation`](/documentation/UIKit/UIViewController/interfaceOrientation) property still contains the view’s original orientation. Your implementation of this method must call `super` at some point during its execution.

This method is called regardless of whether your code performs one-step or two-step rotations.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)