iPhone check firmware version

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-30 04:07:36

You will need to use pre-processor directives for the conditional compilation such as __IPHONE_3_0 and build two separate executables.

For example:

 #ifdef __IPHONE_3_0
 // code specific to version 3
 #else
 // code specific to version 2
 #end

If you need to detect the version at run-time you can use [[UIDevice currentDevice] systemVersion]. It returns the string with the current version of the iPhone OS.

Kriem

As I mentioned in the comments before, check: How to target a specific iPhone version?

As mentioned in the other referenced thread, while you can use pre-processor directives to generate two applications from one code base, you will still need two applications (one for 2.x and one for 3.x)

A compile time directive cannot be used to make a run time decision.

There's more detail in the other thread.

Alternate solution, just check using respondsToSelector. For example-

CGSize expectedLabelSize;
    if ([subTitle respondsToSelector:@selector(sizeWithAttributes:)])
    {
        expectedLabelSize = [subTitle sizeWithAttributes:@{NSFontAttributeName:subTitleLabel.font}];
    }else{
        expectedLabelSize = [subTitle sizeWithFont:subTitleLabel.font constrainedToSize:subTitleLabel.frame.size lineBreakMode:NSLineBreakByWordWrapping];
    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!