UIDevice
A representation of the current device.
Declaration
@MainActor class UIDeviceOverview
Use a UIDevice object to get information about the device such as assigned name, device model, and operating-system name and version. You also use the UIDevice instance to detect changes in the device’s characteristics, such as physical orientation. You get the current orientation using the orientation property or receive change notifications by registering for the orientationDidChangeNotification notification. Before using either of these techniques to get orientation data, you must enable data delivery using the beginGeneratingDeviceOrientationNotifications() method. When you no longer need to track the device orientation, call the endGeneratingDeviceOrientationNotifications() method to disable the delivery of notifications.
Similarly, you can use the UIDevice instance to obtain information and notifications about changes to the battery’s charge state (described by the batteryState property) and charge level (described by the batteryLevel property). The UIDevice instance also provides access to the proximity sensor state (described by the proximityState property). The proximity sensor detects whether the user is holding the device close to their face. Enable battery monitoring or proximity sensing only when you need it.
You can also use the playInputClick() instance method to play keyboard input clicks in custom input and keyboard accessory views.
Topics
Getting the shared device instance
Identifying the device and operating system
Determining the available features
Tracking the device orientation
orientationUIDeviceOrientationisGeneratingDeviceOrientationNotificationsbeginGeneratingDeviceOrientationNotifications()endGeneratingDeviceOrientationNotifications()
Determining the current orientation
Getting the device battery state
Using the proximity sensor
Playing input clicks
Getting the current idiom
Managing notifications
batteryLevelDidChangeNotificationbatteryStateDidChangeNotificationorientationDidChangeNotificationproximityStateDidChangeNotification