ios开发中各种版本、设备的区分的代码
把开发过程中比较好的内容段做个收藏,如下的内容是关于 ios开发中各种版本、设备的区分的内容。
if ([modelname isEqualToString:@"iPhone"]) {}if ([modelname isEqualToString:@"IPod Touch"]) {}if ([modelname isEqualToString:@"iPhone Simulator"]) {}也可以通过宏定义区分#if TARGET_OS_IPHONE#endif#if TARGET_IPHONE_SIMULATOR#endif#if !TARGET_IPHONE_SIMULATOR#endifios设备版本的区分-iphone3gs,iphone4....ios提供了几种c函数来获得相应信息如下struct utsname u;if ([machine isEqualToString:@"iPhone1,1"]) {}if ([machine isEqualToString:@"iPhone1,2"]) {}if ([machine isEqualToString:@"iPhone2,1"]) {}if ([machine isEqualToString:@"iPod1,1"]) {}if ([machine isEqualToString:@"iPod2,1"]) {}if ([machine isEqualToString:@"iPod3,1"]) {}或者{ size_t size; sysctlbyname("hw.machine", NULL, &size, NULL, 0); Possible values: "iPhone1,1" = iPhone 1G "iPhone1,2" = iPhone 3G "iPhone2,1" = iPhone 3GS "iPod1,1" = iPod touch 1G "iPod2,1" = iPod touch 2G free(machine); return platform;}
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。