screen-orientation-lock

Views must not restrict their view and operation to a single display orientation, such as portrait or landscape.

Who might be affected
Motor/Mobility
Cognitive
Keyboard

Description

Some assistive technologies do not support a certain screen orientation or their users may be unable to access the orientation features of the device. When an app is restricted to only one orientation these users may not be able to use it.

Quick Fixes

iOS

Xcode GUI (applies to the entire app)

Esure that under “Device Orientation” all the checkboxes are either unchecked (the default) or checked.

XCode GUI with the Device Orientation section highlighted. All the checkboxes are unchecked.

UIKit (applies to the entire app)

(Bad)
1// BAD
2@main
3class AppDelegate: UIResponder, UIApplicationDelegate {
4
5 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
6 // Override point for customization after application launch.
7 return true
8 }
9
10 func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
11 .portrait
12 }
13
14 // MARK: UISceneSession Lifecycle
15
16 func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
17 // Called when a new scene session is being created.
18 // Use this method to select a configuration to create the new scene with.
19 return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
20
21 }
22}
(Good)
1@main
2class AppDelegate: UIResponder, UIApplicationDelegate {
3
4 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
5 // Override point for customization after application launch.
6 return true
7 }
8
9 // MARK: UISceneSession Lifecycle
10
11 func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
12 // Called when a new scene session is being created.
13 // Use this method to select a configuration to create the new scene with.
14 return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
15 }
16}
1@main
2class AppDelegate: UIResponder, UIApplicationDelegate {
3
4 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
5 // Override point for customization after application launch.
6 return true
7 }
8
9 func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
10 .all
11 }
12
13 // MARK: UISceneSession Lifecycle
14
15 func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
16 // Called when a new scene session is being created.
17 // Use this method to select a configuration to create the new scene with.
18 return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
19 }
20}
1@main
2class AppDelegate: UIResponder, UIApplicationDelegate {
3
4 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
5 // Override point for customization after application launch.
6 return true
7 }
8
9 func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
10 .allButUpsideDown
11 }
12
13 // MARK: UISceneSession Lifecycle
14
15 func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
16 // Called when a new scene session is being created.
17 // Use this method to select a configuration to create the new scene with.
18 return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
19 }
20}

UIKit (specific view controller)

(Bad)
1class ViewController: UIViewController {
2
3 override func viewDidLoad() {
4 super.viewDidLoad()
5 // Do any additional setup after loading the view.
6 }
7
8 override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
9get { .portrait }
10 }
11}
(Good)
1import UIKit
2
3class ViewController: UIViewController {
4
5 override func viewDidLoad() {
6 super.viewDidLoad()
7 // Do any additional setup after loading the view.
8 }
9
10 override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
11get { .all }
12 }
13}

Android

AndroidManifest.xml

(Bad)
1<activity
2 android:name=".presentation.main.MainActivity"
3 android:launchMode="singleInstance"
4 android:screenOrentation="landscape"
5 tools:ignore="LockedOrientationActivity">
6 <intent-filter>
7 <action android:name="android.intent.action.MAIN" />
8 <actegory android:name="android.intent.category.LAUNCHER" />
9 </intent-filter>
10</activity>
(Bad)
1<activity
2 android:name=".presentation.main.MainActivity"
3 android:launchMode="singleInstance"
4 android:screenOrentation="portrait"
5 tools:ignore="LockedOrientationActivity">
6 <intent-filter>
7 <action android:name="android.intent.action.MAIN" />
8 <actegory android:name="android.intent.category.LAUNCHER" />
9 </intent-filter>
10</activity>
(Good, no screen orientation is specified)
1
2<activity
3 android:name=".presentation.main.MainActivity"
4 android:launchMode="singleInstance">
5 <intent-filter>
6 <action android:name="android.intent.action.MAIN" />
7 <actegory android:name="android.intent.category.LAUNCHER" />
8 </intent-filter>
9</activity>
(Good, no screen orientation is specified)
1<activity
2 android:name=".presentation.main.MainActivity"
3 android:launchMode="singleInstance"
4 android:screenOrentation="unspecified">
5 <intent-filter>
6 <action android:name="android.intent.action.MAIN" />
7 <actegory android:name="android.intent.category.LAUNCHER" />
8 </intent-filter>
9</activity>

How Users Are Affected

Users of assistive technologies which support only a specific screen orientation may not be able to perceive the content or use the app.

WCAG Success criteria

This issue might cause elements to fail one or more of the following Success criteria:
1.3.4 Orientation (AA)