IOS Get device information

Source: Internet
Author: User

-(void) viewdidload

{

[Super Viewdidload];

Get current device operating system and version

NSString *systemname =[[uidevice Currentdevice]systemname];

NSString *system =[[uidevice currentdevice]systemversion];

NSLog (@ "%@%@", Systemname,system);

Get Run app Device

NSString *hardware =[[uidevice Currentdevice]model];

NSLog (@ "%@", hardware);

Device battery charge 0-1.0

float electricquantity = [Uidevice currentdevice].batterylevel;

NSLog (@ "%f", electricquantity);

/*

Device Battery power status

typedef ns_enum (Nsinteger, uidevicebatterystate) {

Uidevicebatterystateunknown,

Uidevicebatterystateunplugged,//on battery, discharging

Uidevicebatterystatecharging,//plugged in, less than 100%

Uidevicebatterystatefull,//plugged in, at 100%

}; Available in IPhone 3.0

*/

uidevicebatterystate state = [[Uidevice currentdevice]batterystate];

NSLog (@ "%d", state);

Whether to support multi-task processing

BOOL muchtask =[[uidevice currentdevice]ismultitaskingsupported];

NSLog (@ "%d", muchtask);

Device direction Change Yes change no unchanged

BOOL direction =[uidevice currentdevice].generatesdeviceorientationnotifications;

NSLog (@ "%d", direction);

Change Device orientation

[[Uidevice Currentdevice] begingeneratingdeviceorientationnotifications];

Change Direction End

[[Uidevice Currentdevice] endgeneratingdeviceorientationnotifications];

Near-state detection when you're close to the iphone instead of touching it, the iphone will respond. Yes near message trigger

BOOL Isyes = [[Uidevice currentdevice] proximitystate];

NSLog (@ "%d", isyes);

Uidevice *device = [Uidevice currentdevice];

Device.proximitymonitoringenabled=yes; Allow proximity detection

Trigger

[[Nsnotificationcenter Defaultcenter] Addobserver:self

Selector: @selector (Proximityclick:)

Name:uideviceproximitystatedidchangenotification Object:device];

}

Near message triggering

-(void) Proximityclick: (nsnotification *) Notification {

Uidevice *device = [Notification Object];

NSLog (@ "in proximity:%i", device.proximitystate);

if (device.proximitystate==1) {

}

}

Device Orientation Change

-(void) begingeneratingdeviceorientationnotifications

{

NSLog (@ "Begin ...");

}

End of direction change

-(void) endgeneratingdeviceorientationnotifications

{

NSLog (@ "over ...");

}

IOS Get device information

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.