知識
不管是網(wǎng)站,軟件還是小程序,都要直接或間接能為您產(chǎn)生價值,我們在追求其視覺表現(xiàn)的同時,更側(cè)重于功能的便捷,營銷的便利,運營的高效,讓網(wǎng)站成為營銷工具,讓軟件能切實提升企業(yè)內(nèi)部管理水平和效率。優(yōu)秀的程序為后期升級提供便捷的支持!
IOS獲取設(shè)備信息
發(fā)表時間:2020-10-19
發(fā)布人:葵宇科技
瀏覽次數(shù):72
概要
IOS獲取設(shè)備信息一般是經(jīng)由過程UIDevice,UIScreen,NSBundle,NSLocal等方法,如不雅說要獲取設(shè)備的內(nèi)存、處理器信息,似乎可以按照Unix獲取類似信息方法。
UIDevice供給了多種屬性、類函數(shù)及狀況通知,包含檢測電池電量和定位設(shè)備與鄰近感應(yīng),UIDevice所做的工作就是為應(yīng)用法度榜樣供給用戶及設(shè)備的一些信息。UIDevice類還可以或許收集關(guān)于設(shè)備的各類具體細節(jié),例如機型及iOS版本等。個中大年夜部分屬性都對開辟工作具有積極的幫助感化
代碼示例
- (void) getDeviceInfo { UIDevice* curDev = [UIDevice currentDevice]; /** 設(shè)備體系信息*/ // 設(shè)備名稱 NSLog(@"\tname : %@", curDev.name); // 設(shè)備模式 NSLog(@"\tmodel : %@", curDev.model); // 設(shè)備本地模式 NSLog(@"\tlocalize : %@", curDev.localizedModel); // 體系名稱 NSLog(@"\tos name : %@", curDev.systemName); // 體系版本號 NSLog(@"\tos version : %@", curDev.systemVersion); // 設(shè)備類別:手機,平板電腦 switch (curDev.userInterfaceIdiom) { case UIUserInterfaceIdiomPhone: NSLog(@"\tIdiom : iPhone"); break; case UIUserInterfaceIdiomPad: NSLog(@"\tIdiom : iPad"); break; default: NSLog(@"\tIdiom : Unknow"); break; } // 設(shè)備獨一標識 NSLog(@"\tUUID : %@", curDev.identifierForVendor.UUIDString); /** 設(shè)備偏向 */ // 設(shè)備朝向 switch (curDev.orientation) { case UIDeviceOrientationPortrait: NSLog(@"\torientation : Portrait"); break; case UIDeviceOrientationPortraitUpsideDown: NSLog(@"\torientation : upside down"); break; case UIDeviceOrientationLandscapeLeft: NSLog(@"\torientation : left"); break; case UIDeviceOrientationLandscapeRight: NSLog(@"\torientation : right"); break; case UIDeviceOrientationFaceUp: NSLog(@"\torientation : face up"); break; case UIDeviceOrientationFaceDown: NSLog(@"\torientation : face down"); break; default: NSLog(@"\torientation : Unknow"); break; } UIScreen* mainScreen = [UIScreen mainScreen]; // 屏幕尺寸 NSLog(@"screen size : %.0fx%.0f", mainScreen.bounds.size.width, mainScreen.bounds.size.height); /** 設(shè)備電池 */ NSLog(@"Battery infomation"); // 電量 NSLog(@"\tlevel : %.2f%%", curDev.batteryLevel*100); switch (curDev.batteryState) { case UIDeviceBatteryStateUnplugged: NSLog(@"\tstate : Unplugged"); break; case UIDeviceBatteryStateCharging: NSLog(@"\tstate : Charging"); break; case UIDeviceBatteryStateFull: NSLog(@"\tstate : Full"); break; default: NSLog(@"\tstate : Unknow"); break; } // 電池監(jiān)督器是否開啟 if( curDev.isBatteryMonitoringEnabled ) { NSLog(@"\tmonitor on : YES"); } else { NSLog(@"\tmonitor on : NO"); } /** 體感器 */ NSLog(@"Proximity Sensor infomation"); if( curDev.proximityState ) { NSLog(@"\tsensor on : YES"); } else { NSLog(@"\tsensor on : NO"); } if(curDev.proximityMonitoringEnabled) { NSLog(@"\tmonitor on : YES"); } else { NSLog(@"\tmonitor on : NO"); } } - (void) getBundleInfo { NSBundle* bundle = [NSBundle mainBundle]; NSDictionary* bundleInfo = [bundle infoDictionary]; // 應(yīng)用信息 NSLog(@"%@", bundleInfo); /* CFBundleDevelopmentRegion = en; CFBundleExecutable = DeviceInfo; CFBundleIdentifier = "arbboter.com.DeviceInfo"; CFBundleInfoDictionaryVersion = "6.0"; CFBundleInfoPlistURL = "Info.plist -- file:///../DeviceInfo.app/"; CFBundleName = DeviceInfo; CFBundleNumericVersion = 16809984; CFBundlePackageType = APPL; CFBundleShortVersionString = "1.0"; CFBundleSignature = "????"; CFBundleSupportedPlatforms = ( iPhoneSimulator ); CFBundleVersion = 1; DTPlatformName = iphonesimulator; DTSDKName = "iphonesimulator8.1"; LSRequiresIPhoneOS = 1; UIDeviceFamily = ( 1 ); UILaunchStoryboardName = LaunchScreen; UIMainStoryboardFile = Main; UIRequiredDeviceCapabilities = ( armv7 ); UISupportedInterfaceOrientations = ( UIInterfaceOrientationPortrait, UIInterfaceOrientationLandscapeLeft, UIInterfaceOrientationLandscapeRight ); */ }
相關(guān)案例查看更多
相關(guān)閱讀
- 麗江小程序開發(fā)
- APP
- 云南etc微信小程序
- 云南做軟件
- 微分銷
- 開通微信小程序被騙
- 云南網(wǎng)站建設(shè)案例
- 汽車拆解系統(tǒng)
- 網(wǎng)站建設(shè)特性
- 網(wǎng)站制作
- 云南網(wǎng)站建設(shè)哪家好
- 網(wǎng)站建設(shè)公司地址
- 網(wǎng)站優(yōu)化哪家好
- 網(wǎng)站開發(fā)
- 百度推廣
- 云南小程序開發(fā)
- 云南網(wǎng)站建設(shè)選
- 報廢車回收管理系統(tǒng)
- 做小程序被騙
- 網(wǎng)絡(luò)公司排名
- 昆明軟件定制
- 昆明小程序哪家好
- 云南網(wǎng)站維護
- 小程序被攻擊
- 云南網(wǎng)站建設(shè)哪家強
- 報廢車拆解回收管理系統(tǒng)
- 區(qū)塊鏈
- 網(wǎng)站制作哪家好
- 云南網(wǎng)站建設(shè)百度官方
- web