requestGeometryUpdate(_:errorHandler:)
Requests an update to the window scene’s geometry using the specified geometry preferences object.
Declaration
func requestGeometryUpdate(_ geometryPreferences: UIWindowScene.GeometryPreferences, errorHandler: ((any Error) -> Void)? = nil)Parameters
- geometryPreferences:
The geometry information to use for the request.
- errorHandler:
An optional closure to call when an error occurs. The system may call the error handler asynchronously.
Discussion
Use this method to explicitly request geometry changes to the window scene. The following code shows an example of requesting the window scene to rotate to a landscape orientation in iOS.
// In a view controller, get the window scene.
guard let windowScene = view.window?.windowScene else { return }
// Request the window scene to rotate to any landscape orientation.
windowScene.requestGeometryUpdate(.iOS(interfaceOrientations: .landscape)) { error in
// Handle denial of request.
}