The Uidevice class shows some key device-specific attributes, including the iphone used, ipad or ipod touch model, device name, and OS name and version.
He is a one-stop solution for extracting some of the system details. Each method is an instance method, and they are invoked using the Uidevice singleton through [Uidevice Currentdevice].
The system information that can be obtained through Uidevice includes the following items.
1.systemName: It is used to return the name of the operating system that is currently in use. For the current generation of iOS devices, only one os:iphone OS is running on the platform.
2.systemVersion: This value will list the fixed version currently installed on the unit.
The 3.model:iphone model returns a string describing its platform, both IPhone, ipad and ipod Touch. If you extend iOS to a new device, these models will be described using an extra string. Localizedmodel provides a localized version of this property.
4.userInterfaceIdiom: This property represents the interface style used on the current device, both the iphone or ipad. Other terms may be introduced when Apple offers another platform style.
5.name: This string is the name of the iphone specified by the user, and this name is also used to create the local host name of the device.
Uidevice *device =[Uidevice Currentdevice]; NSLog (@"systemName:%@", Device.systemname); NSLog (@"systemversion:%@", device.systemversion); NSLog (@"Model:%@", Device.model); NSLog (@"localizedmodel:%@", Device.localizedmodel); NSLog (@"userinterfaceidiom:%d", Device.userinterfaceidiom); NSLog (@"name:%@", device.name);
Its output value
the- A- A Ten: A:00.301uidevicetest[2526:885673] Systemname:iphone OS the- A- A Ten: A:00.303uidevicetest[2526:885673] Systemversion:8.1.2 the- A- A Ten: A:00.304uidevicetest[2526:885673] Model:iphone the- A- A Ten: A:00.304uidevicetest[2526:885673] Localizedmodel:iphone the- A- A Ten: A:00.304uidevicetest[2526:885673] Userinterfaceidiom:0 the- A- A Ten: A:00.409uidevicetest[2526:885673] Name: "Tato" of the IPhone
For the current version of iOS, a simple Boolean test can be used for style checking. The following example how to implement an ipad check. It is used to test the selector consistency and, if possible, will return [Uidevice Currentdevice].userinterfaceidiom, otherwise, return Uiuserinterfaceidiomphone.
#define Is_ipad (ui_user_interface_idiom () = = Uiuserinterfaceidiompad)
IOS device-specific development: Uidevice