iOS 擷取裝置資訊

來源:互聯網
上載者:User

標籤: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 擷取裝置資訊

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.