How can I make a iPhone app compatible to 2.2.1 and 3.1 SDK?

天涯浪子 提交于 2019-12-05 07:28:36

问题


I have made some apps in 2.2.1 now when I run the same app in 3.1 it gives errors. Changing the codes is a solution I am not looking for. I am looking for some pre-processor directives that can make my app compatible to both SDKs. Something like #ifdef.

Thank You All.


回答1:


Similar to How to target a specific iPhone version?

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
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
}


来源:https://stackoverflow.com/questions/1198129/how-can-i-make-a-iphone-app-compatible-to-2-2-1-and-3-1-sdk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!