2

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.

Nikhil Patel
  • 1,761
  • 12
  • 23
Naresh
  • 363
  • 1
  • 18
  • can you put compile time error and also attach code that you test with condition. – Nitin Gohel Sep 26 '13 at 05:54
  • possible duplicate of [How can we programmatically detect which iOS version is device running on?](http://stackoverflow.com/questions/7848766/how-can-we-programmatically-detect-which-ios-version-is-device-running-on) – Gabriele Petronella Sep 26 '13 at 06:02

2 Answers2

7

use NSFoundationVersionNumber condition for doing this 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

    }

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?

Community
  • 1
  • 1
Nitin Gohel
  • 49,482
  • 17
  • 105
  • 144
  • Hi nitin Thanks a lot for your quick response.Still I am getting the error while compiling the code in IOS6.Error : Use of undeclared identifier "NSFoundationVersionNumber_iOS_6_0" and No visible @interface for "MainViewcontroller" declares the selector 'setNeedsStatusbarAppearanceUpdate'. – Naresh Sep 26 '13 at 05:52
  • its 6.1 not 6.0 my frnd – Nitin Gohel Sep 26 '13 at 06:00
  • please DO NOT use `floatValue` since it may lead to unexpected behaviors. For instance `[@"7.0.1" floatValue] < [@"7.0.2" floatValue]` => NO – Gabriele Petronella Sep 26 '13 at 06:06
1

Try checking for this condition :

if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) {
    // iOS 7
} else {
    // iOS 6
}
Nikhil Patel
  • 1,761
  • 12
  • 23
  • Hi Nikhil thanks for your reply.Still I am getting the error.So please let me know any other way if you can. – Naresh Oct 03 '13 at 05:05