IOS device-specific development: Uidevice

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.