Enumeration

UIInterfaceOrientation

The orientation of the app's user interface.

Overview

Starting in iOS 8, you should employ the UITraitCollection and UITraitEnvironment APIs, and size class properties as used in those APIs, instead of using UIInterfaceOrientation constants or otherwise writing your app in terms of interface orientation.

In earlier versions of iOS, you used these constants in the statusBarOrientation property and the setStatusBarOrientation(_:animated:) method. Notice that UIDeviceOrientationLandscapeRightis assigned to UIInterfaceOrientationLandscapeLeft and UIDeviceOrientationLandscapeLeft is assigned to UIInterfaceOrientationLandscapeRight; the reason for this is that rotating the device requires rotating the content in the opposite direction.

Topics

Orientations

case unknown

The orientation of the device cannot be determined.

case portrait

The device is in portrait mode, with the device held upright and the home button on the bottom.

case portraitUpsideDown

The device is in portrait mode but upside down, with the device held upright and the home button at the top.

case landscapeLeft

The device is in landscape mode, with the device held upright and the Home button on the right side.

case landscapeRight

The device is in landscape mode, with the device held upright and the Home button on the left side.

Orientation Checks

var isLandscape: Bool

A Boolean value indicating whether the user interface is currently presented in a landscape orientation.

var isPortrait: Bool

A Boolean value indicating whether the user interface is currently presented in a portrait orientation.

See Also

Managing Interface Geometry

func application(UIApplication, supportedInterfaceOrientationsFor: UIWindow?) -> UIInterfaceOrientationMask

Asks the delegate for the interface orientations to use for the view controllers in the specified window.

func application(UIApplication, willChangeStatusBarOrientation: UIInterfaceOrientation, duration: TimeInterval)

Tells the delegate when the interface orientation of the status bar is about to change.

func application(UIApplication, didChangeStatusBarOrientation: UIInterfaceOrientation)

Tells the delegate when the interface orientation of the status bar has changed.

func application(UIApplication, willChangeStatusBarFrame: CGRect)

Tells the delegate when the frame of the status bar is about to change.

func application(UIApplication, didChangeStatusBarFrame: CGRect)

Tells the delegate when the frame of the status bar has changed.

struct UIInterfaceOrientationMask

These constants are mask bits for specifying a view controller’s supported interface orientations.

class let invalidInterfaceOrientationException: NSExceptionName

This exception is thrown if a view controller or the app returns 0 instead of a valid set of supported interface orientation values. It is also thrown if the orientation returned by a view controller’s preferredInterfaceOrientationForPresentation method does not match one of the view controller’s supported orientations.