---
title: attemptRotationToDeviceOrientation()
framework: uikit
role: symbol
role_heading: Type Method
path: uikit/uiviewcontroller/attemptrotationtodeviceorientation()
---

# attemptRotationToDeviceOrientation()

Attempts to rotate all windows to the orientation of the device.

## Declaration

```swift
class func attemptRotationToDeviceOrientation()
```

## Discussion

Discussion Some view controllers may want to use app-specific conditions to determine what interface orientations are supported. If your view controller does this, when those conditions change, your app should call this class method. The system immediately attempts to rotate to the new orientation.

## See Also

### Related Documentation

- [supportedInterfaceOrientations](uikit/uiviewcontroller/supportedinterfaceorientations.md)

### Deprecated methods

- [setOverrideTraitCollection(_:forChild:)](uikit/uiviewcontroller/setoverridetraitcollection(_:forchild:).md)
- [overrideTraitCollection(forChild:)](uikit/uiviewcontroller/overridetraitcollection(forchild:).md)
- [registerForPreviewing(with:sourceView:)](uikit/uiviewcontroller/registerforpreviewing(with:sourceview:).md)
- [unregisterForPreviewing(withContext:)](uikit/uiviewcontroller/unregisterforpreviewing(withcontext:).md)
- [canPerformUnwindSegueAction(_:from:withSender:)](uikit/uiviewcontroller/canperformunwindsegueaction(_:from:withsender:).md)
- [didRotate(from:)](uikit/uiviewcontroller/didrotate(from:).md)
- [dismissMoviePlayerViewControllerAnimated()](uikit/uiviewcontroller/dismissmovieplayerviewcontrolleranimated().md)
- [forUnwindSegueAction(_:from:withSender:)](uikit/uiviewcontroller/forunwindsegueaction(_:from:withsender:).md)
- [presentMoviePlayerViewControllerAnimated(_:)](uikit/uiviewcontroller/presentmovieplayerviewcontrolleranimated(_:).md)
- [rotatingFooterView()](uikit/uiviewcontroller/rotatingfooterview().md)
- [rotatingHeaderView()](uikit/uiviewcontroller/rotatingheaderview().md)
- [segueForUnwinding(to:from:identifier:)](uikit/uiviewcontroller/segueforunwinding(to:from:identifier:).md)
- [shouldAutomaticallyForwardRotationMethods()](uikit/uiviewcontroller/shouldautomaticallyforwardrotationmethods().md)
- [willAnimateRotation(to:duration:)](uikit/uiviewcontroller/willanimaterotation(to:duration:).md)
- [willRotate(to:duration:)](uikit/uiviewcontroller/willrotate(to:duration:).md)
