中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

iOS獲取設備信息

2018-07-20    來源:open-open

容器云強勢上線!快速搭建集群,上萬Linux鏡像隨意使用

獲取iOS設備信息需要用到UIDevice類,UIDevice.h文件定義了這些屬性:

    @property(nonatomic,readonly,retain) NSString    *name;              // e.g. "My iPhone"  
    @property(nonatomic,readonly,retain) NSString    *model;             // e.g. @"iPhone", @"iPod touch"  
    @property(nonatomic,readonly,retain) NSString    *localizedModel;    // localized version of model  
    @property(nonatomic,readonly,retain) NSString    *systemName;        // e.g. @"iOS"  
    @property(nonatomic,readonly,retain) NSString    *systemVersion;     // e.g. @"4.0"  
    @property(nonatomic,readonly) UIDeviceOrientation orientation;       // return current device orientation.  this will return UIDeviceOrientationUnknown unless device orientation notifications are being generated.  
      
    @property(nonatomic,readonly,retain) NSUUID      *identifierForVendor NS_AVAILABLE_IOS(6_0);      // a UUID that may be used to uniquely identify the device, same across apps from a single vendor.  
      
    @property(nonatomic,readonly,getter=isGeneratingDeviceOrientationNotifications) BOOL generatesDeviceOrientationNotifications;  
      
    @property(nonatomic,getter=isBatteryMonitoringEnabled) BOOL batteryMonitoringEnabled NS_AVAILABLE_IOS(3_0);  // default is NO  
    @property(nonatomic,readonly) UIDeviceBatteryState          batteryState NS_AVAILABLE_IOS(3_0);  // UIDeviceBatteryStateUnknown if monitoring disabled  
    @property(nonatomic,readonly) float                         batteryLevel NS_AVAILABLE_IOS(3_0);  // 0 .. 1.0. -1.0 if UIDeviceBatteryStateUnknown  
      
    @property(nonatomic,getter=isProximityMonitoringEnabled) BOOL proximityMonitoringEnabled NS_AVAILABLE_IOS(3_0); // default is NO  
    @property(nonatomic,readonly)                            BOOL proximityState NS_AVAILABLE_IOS(3_0);  // always returns NO if no proximity detector  
      
    @property(nonatomic,readonly,getter=isMultitaskingSupported) BOOL multitaskingSupported NS_AVAILABLE_IOS(4_0);  
      
    @property(nonatomic,readonly) UIUserInterfaceIdiom userInterfaceIdiom NS_AVAILABLE_IOS(3_2);  

下面通過簡單例子介紹這些屬性!

環(huán)境:Xcode 6.1,iOS 8.1

設備:iPhone 4s(iOS 7.1.1)

代碼如下:

    // 獲取設備信息  
    - (void) getDevInfo  
    {  
        UIDevice* myDevice = [UIDevice currentDevice];  
        NSLog(@"設備名稱 - %@", myDevice.name);  
        NSLog(@"設備模式 - %@", myDevice.model);  
        NSLog(@"設備本地模式 - %@", myDevice.localizedModel);  
        NSLog(@"系統(tǒng)名稱 - %@", myDevice.systemName);  
        NSLog(@"系統(tǒng)版本 - %@", myDevice.systemVersion);  
          
    //    typedef NS_ENUM(NSInteger, UIDeviceOrientation) {  
    //        UIDeviceOrientationUnknown,  
    //        UIDeviceOrientationPortrait,            // Device oriented vertically, home button on the bottom  
    //        UIDeviceOrientationPortraitUpsideDown,  // Device oriented vertically, home button on the top  
    //        UIDeviceOrientationLandscapeLeft,       // Device oriented horizontally, home button on the right  
    //        UIDeviceOrientationLandscapeRight,      // Device oriented horizontally, home button on the left  
    //        UIDeviceOrientationFaceUp,              // Device oriented flat, face up  
    //        UIDeviceOrientationFaceDown             // Device oriented flat, face down  
    //    };  
        NSLog(@"設備朝向 - %d", myDevice.orientation);  // 詳見UIDeviceOrientation  
          
        NSLog(@"設備UUID - %@", myDevice.identifierForVendor);  
          
        // 當前設備是否有轉向通知  
        NSLog(@"設備轉向通知(BOOL) - %hhd", myDevice.generatesDeviceOrientationNotifications);  
          
        // 是否啟動電池監(jiān)控,默認為NO  
        NSLog(@"電池監(jiān)控啟用狀態(tài)(BOOL) - %hhd", myDevice.batteryMonitoringEnabled);  
          
    //    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  
        NSLog(@"電池狀態(tài) - %d", myDevice.batteryState);  // 詳見UIDeviceBatteryState  
          
        // 電量百分比, 0到1.0,如果電池狀態(tài)為UIDeviceBatteryStateUnknown,則百分比為-1.0  
        NSLog(@"電池電量 - %f", myDevice.batteryLevel);  
          
        // 是否啟動接近監(jiān)控(比如臉接近手機屏),默認為NO  
        NSLog(@"接近監(jiān)控啟用狀態(tài)(BOOL) - %hhd", myDevice.proximityMonitoringEnabled);  
          
        // 如果沒有接近感應器,則返回NO  
        NSLog(@"接近狀態(tài)(BOOL) - %hhd", myDevice.proximityState);  
          
        NSLog(@"是否支持多任務(BOOL) - %hhd", myDevice.multitaskingSupported);  
          
    //    typedef NS_ENUM(NSInteger, UIUserInterfaceIdiom) {  
    //        UIUserInterfaceIdiomUnspecified = -1,  
    //#if __IPHONE_3_2 <= __IPHONE_OS_VERSION_MAX_ALLOWED  
    //        UIUserInterfaceIdiomPhone,           // iPhone and iPod touch style UI  
    //        UIUserInterfaceIdiomPad,             // iPad style UI  
    //#endif  
    //    };  
        NSLog(@"用戶界面模式 - %d", myDevice.userInterfaceIdiom);  // 詳見UIUserInterfaceIdiom  
    }  

打印結果:
    2015-01-29 11:35:23.294 TestProject[261:60b] 設備名稱 - iPhone  
    2015-01-29 11:35:23.297 TestProject[261:60b] 設備模式 - iPhone  
    2015-01-29 11:35:23.298 TestProject[261:60b] 設備本地模式 - iPhone  
    2015-01-29 11:35:23.300 TestProject[261:60b] 系統(tǒng)名稱 - iPhone OS  
    2015-01-29 11:35:23.302 TestProject[261:60b] 系統(tǒng)版本 - 7.1.1  
    2015-01-29 11:35:23.303 TestProject[261:60b] 設備朝向 - 0  
    2015-01-29 11:35:23.311 TestProject[261:60b] 設備UUID - <__NSConcreteUUID 0x16565a90> 7737D97A-35F6-4C0E-B0EC-DF1D711D99E1  
    2015-01-29 11:35:23.313 TestProject[261:60b] 設備轉向通知(BOOL) - 0  
    2015-01-29 11:35:23.314 TestProject[261:60b] 電池監(jiān)控啟用狀態(tài)(BOOL) - 0  
    2015-01-29 11:35:23.316 TestProject[261:60b] 電池狀態(tài) - 0  
    2015-01-29 11:35:23.317 TestProject[261:60b] 電池電量 - -1.000000  
    2015-01-29 11:35:23.319 TestProject[261:60b] 接近監(jiān)控啟用狀態(tài)(BOOL) - 0  
    2015-01-29 11:35:23.321 TestProject[261:60b] 接近狀態(tài)(BOOL) - 0  
    2015-01-29 11:35:23.322 TestProject[261:60b] 是否支持多任務(BOOL) - 1  
    2015-01-29 11:35:23.324 TestProject[261:60b] 用戶界面模式 - 0  

標簽: isp 代碼

版權申明:本站文章部分自網(wǎng)絡,如有侵權,請聯(lián)系:west999com@outlook.com
特別注意:本站所有轉載文章言論不代表本站觀點!
本站所提供的圖片等素材,版權歸原作者所有,如需使用,請與原作者聯(lián)系。

上一篇:PHP緩存類

下一篇:NSURLRequest 簡單的網(wǎng)絡請求