问题
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.
回答1:
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?
回答2:
Try checking for this condition :
if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) {
// iOS 7
} else {
// iOS 6
}
来源:https://stackoverflow.com/questions/19020244/how-to-execute-a-block-of-code-in-ios7-not-in-ios6