不同iOS版本做代码适配

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




__IPHONE_OS_VERSION_MIN_REQUIRED:最低iOS版本要求

__IPHONE_OS_VERSION_MAX_ALLOWED:允许最大的iOS版本

 

#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键,点击查看更多官方定义的宏。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值