Class

UIDevice

The UIDevice class provides a Singleton instance representing the current device. From this instance you can obtain information about the device such as assigned name, device model, and operating-system name and version.

Overview

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 UIDevice​Orientation​Did​Change notification. Before using either of these techniques to get orientation data, you must enable data delivery using the begin​Generating​Device​Orientation​Notifications() method. When you no longer need to track the device orientation, call the end​Generating​Device​Orientation​Notifications() 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 battery​State property) and charge level (described by the battery​Level property). The UIDevice instance also provides access to the proximity sensor state (described by the proximity​State 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.

Starting in iOS 4.2, you can use the play​Input​Click() instance method to play keyboard input clicks in custom input and keyboard accessory views.

Symbols

Getting the Shared Device Instance

class var current:​ UIDevice

Returns an object representing the current device.

Determining the Available Features

var is​Multitasking​Supported:​ Bool

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

Identifying the Device and Operating System

var name:​ String

The name identifying the device.

var system​Name:​ String

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

var system​Version:​ String

The current version of the operating system.

var model:​ String

The model of the device.

var localized​Model:​ String

The model of the device as a localized string.

var user​Interface​Idiom:​ UIUser​Interface​Idiom

The style of interface to use on the current device.

var identifier​For​Vendor:​ UUID?

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

Getting the Device Orientation

var orientation:​ UIDevice​Orientation

Returns the physical orientation of the device.

var is​Generating​Device​Orientation​Notifications:​ Bool

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

func begin​Generating​Device​Orientation​Notifications()

Begins the generation of notifications of device orientation changes.

func end​Generating​Device​Orientation​Notifications()

Ends the generation of notifications of device orientation changes.

Getting the Device Battery State

var battery​Level:​ Float

The battery charge level for the device.

var is​Battery​Monitoring​Enabled:​ Bool

A Boolean value indicating whether battery monitoring is enabled (true) or not (false).

Using the Proximity Sensor

var is​Proximity​Monitoring​Enabled:​ Bool

A Boolean value indicating whether proximity monitoring is enabled (true) or not (false).

var proximity​State:​ Bool

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

Playing Input Clicks

func play​Input​Click()

Plays an input click in an enabled input view.

Constants

UIDevice​Battery​StateUIDevice​Orientation
UIUser​Interface​Idiom

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

Notifications

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

Relationships

Inherits From