Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion screen-orientation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,25 @@ For also lock presented View Controllers, this code can be added to the app's `A

```swift
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
return UIInterfaceOrientationMask(rawValue: (self.window!.rootViewController as! CAPBridgeViewController).supportedInterfaceOrientations.rawValue)
guard let bridgeViewController = window?.rootViewController as? CAPBridgeViewController else {
return .all
}
return bridgeViewController.supportedInterfaceOrientations
}
```

> **Warning**
>
> If your app already has an earlier version of this snippet, update it. Capacitor 8.5 and later adopt the UIScene lifecycle, in which the window is owned by `SceneDelegate`, so `self.window` on the `AppDelegate` is always `nil` and the previous snippet crashes on launch. Read the root view controller from the `window` passed into the method instead:
>
> ```diff
> - return UIInterfaceOrientationMask(rawValue: (self.window!.rootViewController as! CAPBridgeViewController).supportedInterfaceOrientations.rawValue)
> + guard let bridgeViewController = window?.rootViewController as? CAPBridgeViewController else {
> + return .all
> + }
> + return bridgeViewController.supportedInterfaceOrientations
> ```
### iPad Orientation Lock
By default, an iPad allows Multitasking and its orientation cannot be locked. If you need to lock orientation on an iPad set the option `Requires Full Screen` to `YES` by adding the following to `Info.plist`:
Expand Down
Loading