如何定位特定的iPhone版本? [英] How to target a specific iPhone version?

查看:99
本文介绍了如何定位特定的iPhone版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些代码我只想在最新的iPhone SDK(3.0)上执行,但我似乎无法找到一种方法来定位3.0并忽略2.2.1等。有一个ifdef语句,但它似乎只涵盖整个iPhone:

I've got some code I want to only execute on the latest iPhone SDK (3.0), however I can't seem to figure out a way to target just 3.0 and ignore 2.2.1 etc. There is an ifdef statement, but it just seems to cover the entire iPhone:

#if TARGET_OS_IPHONE

感谢任何帮助。

推荐答案

你可以使用这个#define改变你为每个SDK构建的内容...

You can use this #define to change what you build for each SDK...

#if __IPHONE_OS_VERSION_MIN_REQUIRED > __IPHONE_2_2
// iPhone 3.0 code here
#endif

并且执行此操作运行时运行3.0及以上的代码:

And do this at run-time to run code for 3.0 and above:

float version = [[[UIDevice currentDevice] systemVersion] floatValue];
if (version >= 3.0)
    {
    // iPhone 3.0 code here
    }

这篇关于如何定位特定的iPhone版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆