使用iPhone SDK确定设备(iPhoneiPod Touch)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用iPhone SDK确定设备(iPhoneiPod Touch)相关的知识,希望对你有一定的参考价值。
Here is how to determine the device type. How to use it. UIDeviceHardware *h=[[UIDeviceHardware alloc] init]; [self setDeviceModel:[h platformString]]; [h release];
// // UIDeviceHardware.h // // Used to determine EXACT version of device software is running on. #import <Foundation/Foundation.h> @end // // UIDeviceHardware.m // // Used to determine EXACT version of device software is running on. #import "UIDeviceHardware.h" #include <sys/types.h> #include <sys/sysctl.h> @implementation UIDeviceHardware size_t size; sysctlbyname("hw.machine", NULL, &size, NULL, 0); sysctlbyname("hw.machine", machine, &size, NULL, 0); return platform; } if ([platform isEqualToString:@"iPhone1,1"]) return @"iPhone 1G"; if ([platform isEqualToString:@"iPhone1,2"]) return @"iPhone 3G"; if ([platform isEqualToString:@"iPhone2,1"]) return @"iPhone 3GS"; if ([platform isEqualToString:@"iPhone3,1"]) return @"iPhone 4"; if ([platform isEqualToString:@"iPod1,1"]) return @"iPod Touch 1G"; if ([platform isEqualToString:@"iPod2,1"]) return @"iPod Touch 2G"; if ([platform isEqualToString:@"iPod3,1"]) return @"iPod Touch 3G"; if ([platform isEqualToString:@"i386"]) return @"iPhone Simulator"; return platform; } @end
以上是关于使用iPhone SDK确定设备(iPhoneiPod Touch)的主要内容,如果未能解决你的问题,请参考以下文章
Iphone 4 sdk - 如何确定 applicationWillEnterForeground 是不是因通知而被触发?
如何以编程方式确定应用程序正在iphone或ipod中运行[重复]
如何使用 iOS 6 sdk 为 iPhone 4s 或 iPhone 4 制作视图控制器?
iphone sdk - Itunes connect 如何更改设备要求?