下面是内存溢出 jb51.cc 通过网络收集整理的代码片段。
内存溢出小编现在分享给大家,也给大家做个参考。
@property(nonatomic,Readonly,retain) Nsstring *name; // e.g. "My iPhone" @property(nonatomic,retain) Nsstring *model; // e.g. @"iPhone",@"iPod touch" @property(nonatomic,retain) Nsstring *localizedModel; // localized version of model @property(nonatomic,retain) Nsstring *systemname; // e.g. @"iOS" @property(nonatomic,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,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,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,getter=isMultitaskingSupported) BOol multitaskingSupported NS_AVAILABLE_IOS(4_0); @property(nonatomic,Readonly) UIUserInterfaceIdiom userInterfaceIdiom NS_AVAILABLE_IOS(3_2);
下面通过简单例子介绍这些属性!
// 获取设备信息 - (voID) getDevInfo { UIDevice* myDevice = [UIDevice currentDevice]; NSLog(@"设备名称 - %@",myDevice.name); NSLog(@"设备模式 - %@",myDevice.model); NSLog(@"设备本地模式 - %@",myDevice.localizedModel); NSLog(@"系统名称 - %@",myDevice.systemname); NSLog(@"系统版本 - %@",myDevice.systemVersion); // typedef NS_ENUM(NSInteger,UIDeviceOrIEntation) { // UIDeviceOrIEntationUnkNown,// UIDeviceOrIEntationPortrait,// Device orIEnted vertically,home button on the bottom // UIDeviceOrIEntationPortraitUpsIDeDown,home button on the top // UIDeviceOrIEntationLandscapeleft,// Device orIEnted horizontally,home button on the right // UIDeviceOrIEntationLandscapeRight,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); // 是否启动电池监控,默认为NO NSLog(@"电池监控启用状态(BOol) - %hhd",myDevice.batteryMonitoringEnabled); // typedef NS_ENUM(NSInteger,UIDeviceBatteryState) { // UIDeviceBatteryStateUnkNown,// UIDeviceBatteryStateUnplugged,// on battery,discharging // UIDeviceBatteryStateCharging,// plugged in,less than 100% // UIDeviceBatteryStateFull,at 100% // }; // available in iPhone 3.0 NSLog(@"电池状态 - %d",myDevice.batteryState); // 详见UIDeviceBatteryState // 电量百分比, 0到1.0,如果电池状态为UIDeviceBatteryStateUnkNown,则百分比为-1.0 NSLog(@"电池电量 - %f",myDevice.batterylevel); // 是否启动接近监控(比如脸接近手机屏),默认为NO NSLog(@"接近监控启用状态(BOol) - %hhd",myDevice.proximityMonitoringEnabled); // 如果没有接近感应器,则返回NO NSLog(@"接近状态(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] 系统名称 - iPhone OS 2015-01-29 11:35:23.302 TestProject[261:60b] 系统版本 - 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] 电池监控启用状态(BOol) - 0 2015-01-29 11:35:23.316 TestProject[261:60b] 电池状态 - 0 2015-01-29 11:35:23.317 TestProject[261:60b] 电池电量 - -1.000000 2015-01-29 11:35:23.319 TestProject[261:60b] 接近监控启用状态(BOol) - 0 2015-01-29 11:35:23.321 TestProject[261:60b] 接近状态(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
以上是内存溢出(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
总结以上是内存溢出为你收集整理的iOS获取设备信息全部内容,希望文章能够帮你解决iOS获取设备信息所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)