标签:io os ar sp on cti log ad ef
- (void)viewDidLoad
{
[super viewDidLoad];
//获取当前设备操作系统及版本
NSString *systemName =[[UIDevice currentDevice]systemName];
NSString *system =[[UIDevice currentDevice]systemVersion];
NSLog(@"%@ %@",systemName,system);
//获取运行应用设备
NSString *hardware =[[UIDevice currentDevice]model];
NSLog(@"%@",hardware);
//设备电池电量0-1.0
float electricQuantity = [UIDevice currentDevice].batteryLevel;
NSLog(@"%f",electricQuantity);
/*
设备电池电量状态
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);
//是否支持多任务处理
BOOL muchTask =[[UIDevice currentDevice]isMultitaskingSupported];
NSLog(@"%d",muchTask);
//设备方向改变 YES改变 NO未变
BOOL direction =[UIDevice currentDevice].generatesDeviceOrientationNotifications ;
NSLog(@"%d",direction);
//改变设备方向
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications ];
//改变方向结束
[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
//靠近状态检测 当你靠近iPhone而不是触摸的时候,iPhone将会做出反应。 YES临近消息触发
BOOL isYes = [[UIDevice currentDevice] proximityState];
NSLog(@"%d",isYes);
UIDevice *device = [UIDevice currentDevice];
device.proximityMonitoringEnabled=YES; //允许临近检测
//触发
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(proximityClick:)
name:UIDeviceProximityStateDidChangeNotification object:device];
}
//临近消息触发
- (void) proximityClick:(NSNotification *)notification {
UIDevice *device = [notification object];
NSLog(@"In proximity:%i",device.proximityState);
if(device.proximityState==1){
}
}
//设备方向改变
- (void)beginGeneratingDeviceOrientationNotifications
{
NSLog(@"begin...");
}
//方向改变结束
- (void)endGeneratingDeviceOrientationNotifications
{
NSLog(@"over...");
}
标签:io os ar sp on cti log ad ef
原文地址:http://www.cnblogs.com/iOS-xiao-lei/p/4015857.html