Class

UIDevice

A representation of the current device.

Overview

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 UIDeviceOrientationDidChangeNotification 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

currentDevice

Returns an object representing the current device.

Determining the Available Features

multitaskingSupported

A Boolean value indicating whether multitasking is supported on the current device.

Identifying the Device and Operating System

name

The name identifying the device.

systemName

The name of the operating system running on the device represented by the receiver.

systemVersion

The current version of the operating system.

model

The model of the device.

localizedModel

The model of the device as a localized string.

userInterfaceIdiom

The style of interface to use on the current device.

identifierForVendor

An alphanumeric string that uniquely identifies a device to the app’s vendor.

Getting the Device Orientation

orientation

Returns the physical orientation of the device.

generatesDeviceOrientationNotifications

A Boolean value that indicates whether the receiver generates orientation notifications (YES) or not (NO).

beginGeneratingDeviceOrientationNotifications

Begins the generation of notifications of device orientation changes.

endGeneratingDeviceOrientationNotifications

Ends the generation of notifications of device orientation changes.

Getting the Device Battery State

batteryLevel

The battery charge level for the device.

batteryMonitoringEnabled

A Boolean value indicating whether battery monitoring is enabled (YES) or not (NO).

batteryState

The battery state for the device.

Using the Proximity Sensor

proximityMonitoringEnabled

A Boolean value indicating whether proximity monitoring is enabled (YES) or not (NO).

proximityState

A Boolean value indicating whether the proximity sensor is close to the user (YES) or not (NO).

Playing Input Clicks

playInputClick

Plays an input click in an enabled input view.

Device Orientation

UIDeviceOrientationIsPortrait

Returns a Boolean value indicating whether the device is in a portrait orientation.

UIDeviceOrientationIsLandscape

Returns a Boolean value indicating whether the device is in a landscape orientation.

Idioms

UIUserInterfaceIdiom

The type of interface that should be used on the current device

UI_USER_INTERFACE_IDIOM

Returns the interface idiom supported by the current device (recommended for apps that run in versions of iOS earlier than 3.2).

Constants

UIDeviceBatteryState

The battery power state of the device.

UIDeviceOrientation

The physical orientation of the device.

Notifications

All UIDevice notifications are posted by the singleton device instance returned by currentDevice.

UIDeviceBatteryLevelDidChangeNotification

Posted when the battery level changes.

UIDeviceBatteryStateDidChangeNotification

Posted when battery state changes.

UIDeviceOrientationDidChangeNotification

Posted when the orientation of the device changes.

UIDeviceProximityStateDidChangeNotification

Posted when the state of the proximity sensor changes.

Relationships

Inherits From

See Also

Device Environment

Responding to Changing Display Modes on Apple TV

Change images and resources dynamically when the screen gamut on your device changes.

UITraitCollection

The iOS interface environment for your app, defined by traits such as horizontal and vertical size class, display scale, and user interface idiom.

UITraitEnvironment

A collection of methods that makes the iOS interface environment available to your app.

UIAdaptivePresentationControllerDelegate

A set of methods that, in conjunction with a presentation controller, determine how to respond to trait changes in your app.