如何在IOS7中执行代码块而不是在IOS6中? [英] How to execute a block of code in IOS7 not in IOS6?

查看:70
本文介绍了如何在IOS7中执行代码块而不是在IOS6中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨在过去,我开发了一个支持IOS6的应用程序。现在是时候来支持IOS7的同一个应用了。为了支持IOS6和App的应用程序IOS7我通过 20像素增加了每个组件的 Y 值。



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



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

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

这些方法在IOS7中运行正常但是如果我在IOS6中安装该应用程序,该应用程序将崩溃到期以上两种方法。



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



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

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

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



所以请帮我解决这个问题。在此先感谢。

解决方案

使用 NSFoundationVersionNumber 执行此操作的条件。下面的代码显示了如何检查Foundation框架版本:




  if(floor(NSFoundationVersionNumber) < = NSFoundationVersionNumber_iOS_6_1){

//为iOS 6.1或更早版本加载资源

} else {

//为iOS 7加载资源或以后

}

看看同样的事情的最佳答案你想要



iOS 7状态栏在iPhone应用程序中恢复为iOS 6默认样式?


Hi In past I had developed one application which supports IOS6.Now the time came to support the same app for IOS7 also. For supporting the app for IOS6 & IOS7 I increased the Y value of each and every component by 20 pixels.

Here I am getting the OS version by using[[[UIDevice CurrentDevice]SystemVersion] floatvalue]; method.Based on that OS version I am changing the rect values for each and every component.

For handling the StatusbarStyle I am using the following methods in IOS7

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

These methods are working fine in IOS7, But if I install the app in IOS6 the app is crashing due to the above two methods.

So now my requirement is I have to hide or not execute IOS7 related methods or changes in IOS6 Device.With the help of this Implementation I hope I can resolve the issue.

Even I used few methods to resolve this crash issue.The methods which I used are

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

Here while creating the ipa file deployment Target Which I had set is 6.0. Because I have to support IOS6 & IOS7.

So please help me to resolve this issue. Thanks in Advance.

解决方案

use NSFoundationVersionNumber condition for doing this Supporting iOS 6

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

    }

Take a look the best answer of the same thing that you want

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

这篇关于如何在IOS7中执行代码块而不是在IOS6中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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