BlackM
BlackM

Reputation: 4065

Approach for UI of iOS 5,6 and 7 - Xcode

I just update my Xcode to 5. I am trying to build my app and it looks very nice on iOS7 but I have problems with the toolbars. The buttons on toolbar are very close to the status bar. IF Ui make some changes then it breakes the UI for iOS 5 and 6. What is the best approach? Building different storyboard for iOS 7 is considered as good approach? Is there any other way to fix the issue with toolbars?

Upvotes: 3

Views: 1330

Answers (1)

Kevin
Kevin

Reputation: 3131

Best approach is just to add a lot of checks to the iOS version before doing any changes. Place the following macros in your *_prefix.pch file

#define SYSTEM_VERSION_EQUAL_TO(v)                  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v)              ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v)                 ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v)     ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)

and then use like this for iOS 7 specific functionality:

if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")) {
    self.automaticallyAdjustsScrollViewInsets = YES;
    // or anything. Above line not specific to question, just an example
}

In Xcode 5 Interface Builder you are also able to specify offsets between iOS 7 & 6 or lower in the Size Inspector (Fourth tab in the Utilities (third) column) and switch between 7 and < 7 renderings in the File Inspector (first tab in the Utilities column). This usually comes into play when you have to account for the status bar or navigation bar in the layouts in 7.

iOS Version Deltas Switch renderings

Upvotes: 7

Related Questions