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.
- iOS 2.0+
- tvOS 2.0+
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
UIDeviceOrientationDidChange 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.
Starting in iOS 4.2, you can use the
playInputClick() instance method to play keyboard input clicks in custom input and keyboard accessory views.