检查 iOS SDK 版本的预处理器和/或宏方法? [英] Preprocessor and/or Macro way to check iOS SDK version?

查看:17
本文介绍了检查 iOS SDK 版本的预处理器和/或宏方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个黑色主题的 iOS 6 和 7 应用程序.我知道我可以调用 [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; 使 iOS 7 状态栏适合深色主题应用程序.

I am buliding a dark themed iOS 6 and 7 app. I understand I can call [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; to make the iOS 7 status bar suit a dark color theme application.

问题是我要将我的应用程序提交到 App Store,而目前 Xcode 5 还没有准备好,所以我必须使用 Xcode 4.6.x 来完成这项任务.但是使用 Xcode 4.6,我无法从 iOS 7 编译新方法.我想我必须执行类似 ""if ios7"" 的操作,然后执行 [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; 并重新定位我的应用程序窗口.

The problem is I am going to submit my app to the App Store and currently Xcode 5 is not ready for that, so I have to use Xcode 4.6.x to do this task. However with Xcode 4.6, I am not able to compile the new method from iOS 7. I think I have to do something like ""if ios7"" then do [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; and reposition my application window.

我正在尝试使用 #ifdef ... #else ...此代码是 viewDidLoad 内的 [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];.

I am trying to do this with #ifdef ... #else... this code is [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; inside the viewDidLoad.

任何人都可以帮助了解如何在某些函数中使用 #ifdef... 方法.

Could anyone help to understand how to use #ifdef... with the method in some functions.

非常感谢!!!!

推荐答案

虽然我不能 100% 确定我可以在不违反 NDA 的情况下完全回答这个问题,但我会尽我所能为您指明正确的方向.

While I'm not 100% sure I can fully answer this without breaching NDA, I'll do my best to point you in the right direction.

p>

您需要使用__IPHONE_* #defines in Availability.h

You need to use the __IPHONE_* #defines in Availability.h

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_6_0 && defined(__IPHONE_6_0)
  // iOS 6+ code here
#else
  // Pre iOS 6 code here
#endif

请注意,#if#ifdef 将决定编译的代码,它不是运行时检测机制.

Please be aware that #if and #ifdef will determine what code is compiled, it is not a runtime detection mechanism.

您可以使用快速打开"并输入可用性"轻松访问 Availability.h.

You can easily access Availability.h by using Open Quickly and typing in Availability.

这篇关于检查 iOS SDK 版本的预处理器和/或宏方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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