首页 技术 正文
技术 2022年11月7日
0 收藏 922 点赞 471 浏览 2742 个字

目前开发只想最低版本支持iOS8了,iOS8以前的就不管了,然后现在iOS9和iOS10出来以后,有些新的API,也有些弃用的API,为了兼容,有时候代码里面需要编写判断不同iOS版本,或者只允许指定的iOS版本才可以编译或者执行。

需要用到以下方式,以下方式只针对OC(Swift的写法暂时还不清楚,等需要的时候在补充):

示例:

//ios8.0以后用此方法替代willRotateToInterfaceOrientation:duration:这个方法
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000
// 视图控制器旋转到某个尺寸
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator
{
    [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
    if (size.height > size.width)
    {
        NSLog(@"-------当前设备方向是竖屏-------");
    }
    else
    {
        NSLog(@"-------当前设备方向是横屏-------");
    }
}
#endif

<!–
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #0433ff}
span.s1 {font-variant-ligatures: no-common-ligatures}
–>

__IPHONE_OS_VERSION_MIN_REQUIRED:最低iOS版本要求

__IPHONE_OS_VERSION_MAX_ALLOWED:允许最大的iOS版本

<!–
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #0433ff}
p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #008f00}
span.s1 {font-variant-ligatures: no-common-ligatures}
span.s2 {font-variant-ligatures: no-common-ligatures; color: #000000}
–>

#define __MAC_10_0            1000

#define __MAC_10_1            1010

#define __MAC_10_2            1020

#define __MAC_10_3            1030

#define __MAC_10_4            1040

#define __MAC_10_5            1050

#define __MAC_10_6            1060

#define __MAC_10_7            1070

#define __MAC_10_8            1080

#define __MAC_10_9            1090

#define __MAC_10_10         101000

#define __MAC_10_10_2       101002

#define __MAC_10_10_3       101003

#define __MAC_10_11         101100

#define __MAC_10_11_2       101102

#define __MAC_10_11_3       101103

#define __MAC_10_11_4       101104

#define __MAC_10_12         101200

/* __MAC_NA is not defined to a value but is uses as a token by macros to indicate that the API is unavailable */

#define __IPHONE_2_0      20000

#define __IPHONE_2_1      20100

#define __IPHONE_2_2      20200

#define __IPHONE_3_0      30000

#define __IPHONE_3_1      30100

#define __IPHONE_3_2      30200

#define __IPHONE_4_0      40000

#define __IPHONE_4_1      40100

#define __IPHONE_4_2      40200

#define __IPHONE_4_3      40300

#define __IPHONE_5_0      50000

#define __IPHONE_5_1      50100

#define __IPHONE_6_0      60000

#define __IPHONE_6_1      60100

#define __IPHONE_7_0      70000

#define __IPHONE_7_1      70100

#define __IPHONE_8_0      80000

#define __IPHONE_8_1      80100

#define __IPHONE_8_2      80200

#define __IPHONE_8_3      80300

#define __IPHONE_8_4      80400

#define __IPHONE_9_0      90000

#define __IPHONE_9_1      90100

#define __IPHONE_9_2      90200

#define __IPHONE_9_3      90300

#define __IPHONE_10_0    100000

/* __IPHONE_NA is not defined to a value but is uses as a token by macros to indicate that the API is unavailable */

#define __TVOS_9_0        90000

#define __TVOS_9_1        90100

#define __TVOS_9_2        90200

#define __TVOS_10_0      100000

#define __WATCHOS_1_0     10000

#define __WATCHOS_2_0     20000

#define __WATCHOS_3_0     30000

  

可以在Xcode 中按住Command键,点击查看更多官方定义的宏。

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,996
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,510
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,353
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,137
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,770
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,848