標籤: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...");
}
iOS 擷取裝置資訊