gpt4 book ai didi

ios - 如何在 IOS 7 中而不是在 IOS 6 中执行代码块?

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:02:45 40 4
gpt4 key购买 nike

您好 过去我开发了一个支持 IOS6 的应用程序。现在是时候为 IOS7 也支持相同的应用程序了。为了支持适用于 IOS6 和 IOS7 的应用程序,我将每个组件的 Y 值增加了 20 像素

在这里,我通过使用[[[UIDevice CurrentDevice]SystemVersion] floatvalue]; 方法获取操作系统版本。基于该操作系统版本,我正在更改 rect 值对于每个组件。

为了处理 StatusbarStyle 我在 IOS7 中使用了以下方法

 1. [self setNeedsStatusBarAppearanceUpdate];
2.-(UIStatusBarStyle)preferredStatusBarStyle;

这些方法在 IOS7 中运行良好,但是如果我在 IOS6 中安装应用程序,应用程序会由于上述两种方法而崩溃。

所以现在我的要求是我必须隐藏或不执行 IOS7 相关方法或 IOS6 设备中的更改。在这个实现的帮助下,我希望我能解决这个问题。

即使我用了很少的方法来解决这个崩溃问题。我使用的方法是

1. #if __IPHONE_OS_VERSION_MAX_ALLOWED== 70000
2.#if __IPHONE_OS_VERSION_MIN_REQUIRED==70000

在这里创建 ipa 文件时,我设置的部署目标是 6.0。因为我必须支持IOS6 & IOS7。

所以请帮我解决这个问题。提前致谢。

最佳答案

使用 NSFoundationVersionNumber 条件来执行此操作 Supporting iOS 6

enter image description here

If you need to load different resources for different app versions—and you currently identify a storyboard or XIB file in your Info.plist file—

you can use the version of the Foundation framework to determine the current system version and load the appropriate resource in application:didFinishLaunchingWithOptions:. The code below shows how to check the Foundation framework version:

 if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {

// Load resources for iOS 6.1 or earlier

} else {

// Load resources for iOS 7 or later

}

看看你想要的同一件事的最佳答案

iOS 7 status bar back to iOS 6 default style in iPhone app?

关于ios - 如何在 IOS 7 中而不是在 IOS 6 中执行代码块?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19020244/

40 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com